@usmangurowa/rcal
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

React Click Away Listener (rcal)

npm version

license

A simple react click away listener component for React applications.

Installation

Install the package using npm:

npm install @usmangurowa/rcal

Install the package using yarn:

yarn add @usmangurowa/rcal

Usage

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.

/@usmangurowa/rcal/

    Package Sidebar

    Install

    npm i @usmangurowa/rcal

    Weekly Downloads

    1

    Version

    1.0.1

    License

    ISC

    Unpacked Size

    4.78 kB

    Total Files

    4

    Last publish

    Collaborators

    • usmangurowa