React Components For Managing Window And Body Event Listeners

The package provides two components (ReactWindow and ReactBody) that simplify the management of window and body event listeners. Inspired by svelte.

How to use it:

1. Install and import.

# Yarn
$ yarn add @stanko/react-window

# NPM
$ npm i @stanko/react-window
import ReactWindow from "@stanko/react-window";
import { ReactBody } from "@stanko/react-window";

2. Basic usage:

<ReactWindow
  onClick={() => {
    console.log("Hello world!");
  }}
  onScroll={() => {
    console.log(`Wheeeeee! ${window.scrollY}px`);
  }}
/>
<ReactBody
  onClick={() => {
    console.log("Hello!");
  }}
/>

Preview:

React Components For Managing Window And Body Event Listeners

Download Details:

Author: Stanko

Live Demo: View The Demo

Download Link: Download The Source Code

Official Website: https://github.com/Stanko/react-window

License: MIT

Add Comment