@catchad/react-window-event

Make adding eventlistener to Window much more react way.

Usage no npm install needed!

<script type="module">
  import catchadReactWindowEvent from 'https://cdn.skypack.dev/@catchad/react-window-event';
</script>

README

react-window-event

Install

yarn add @catchad/react-window-event

Usage

import React, { Component } from 'react';
import ReactWindowEvent from '@catchad/react-window-event';

class WindowEvent extends Component {
  handleScroll = e => {
    console.log(e);
  };
  render() {
    return (
      <div>
        <ReactWindowEvent type="scroll" listener={this.handleScroll} />
      </div>
    );
  }
}

export default WindowEvent;