@usmangurowa/rcal
v1.0.1
Published
A simple react click away listener component
Maintainers
Readme
React Click Away Listener (rcal)
A simple react click away listener component for React applications.
Installation
Install the package using npm:
npm install @usmangurowa/rcalInstall the package using yarn:
yarn add @usmangurowa/rcalUsage
Here's a basic example of how to use @usmangurowa/rcal:
import React from "react";
import ClickAwayListener from "@usmangurowa/rcal";
const App = () => {
const [open, setOpen] = React.useState(false);
return (
<ClickAwayListener as={"ul"} onClickAway={() => setOpen(false)}>
{/* Your component */}
</ClickAwayListener>
);
};
export default App;API
ClickAwayListener
The ClickAwayListener component listen to click events outside of it.
Props:
as(optional): element to render as ul, div, button, e.t.c.onClickAway: function to trigger when clicked outside is detected....props: all other props like className, style, e.t.c.
Contributing
Contributions are welcome! Feel free to open an issue or submit a pull request.
