ideas icon indicating copy to clipboard operation
ideas copied to clipboard

useListeners

Open thchia opened this issue 7 years ago • 0 comments

Not sure if generic Hooks like this will actually turn out to be helpful but throwing it out there.

import { useRef } from 'react'

function MyComponent() {
  let node = useRef(null)

  useListeners(node, [
    ['click', handleClick],
    ['mousedown', handleMousedown]
  ])

  return <div ref={node} />
}

https://github.com/thchia/useListeners

thchia avatar Oct 26 '18 11:10 thchia