@flexcodelabs/use-events-hooks
TypeScript icon, indicating that this package has built-in type declarations

0.1.0 • Public • Published

npm NPM

Package Name

Installation

npm install @flexcodelabs/use-events-hooks

or

yarn add @flexcodelabs/use-events-hooks

Usage

...
import { useEventListener, useWindowSize, useClickOutsideListener} from '@flexcodelabs/use-events-hooks';

const Test = () => {
  const buttonRef = useRef(null);

  // window size
  const { width, height } = useWindowSize();

  // event listener
  useEventListener("scroll", () => {
    console.log("scrolled");
  });

  // detect outside clicks
  useClickOutsideListener(buttonRef, () => {
    console.log("clicked outside");
  });

  return (
    <div>
      viewport size: {width}x{height}
      <button ref={buttonRef}>Text</button>
    </div>
  );
};

Examples

Source code

Readme

Keywords

none

Package Sidebar

Install

npm i @flexcodelabs/use-events-hooks

Weekly Downloads

0

Version

0.1.0

License

ISC

Unpacked Size

9.16 kB

Total Files

19

Last publish

Collaborators

  • neicore
  • bmsteven
  • baharajr