JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 11
  • Score
    100M100P100Q50391F
  • License MIT

A react hook to add an event listener to a ref

Package Exports

  • @rooks/use-event-listener-ref

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@rooks/use-event-listener-ref) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

@rooks/use-event-listener-ref

TitleCard

Build Status

About

A react hook to add an event listener to a ref

Installation

npm install --save @rooks/use-event-listener-ref

Importing the hook

import useEventListenerRef from "@rooks/use-event-listener-ref"

Usage

function Demo() {
  const ref = useEventListenerRef("click", function(){
    console.log("clicked")
  });
  return <div ref={ref}>
    Click me
  </div>
}

render(<Demo/>)