react-hook-event
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

React Hook Event

import {useEmitter, useEvent} from "react-hook-event";

const ComponentB = () => {
    const emit = useEmitter();
    
    return (
        <button 
          onClick={() => emit('click', 1,2,3,4)}
        >
          Click
        </button>
    )
}

const ComponentA = () => {
    useEvent('click', (...values) => {
        console.log(...values);// => 1, 2, 3, 4
    })

    return <div>
        <ComponentB/>
    </div>
}

Package Sidebar

Install

npm i react-hook-event

Weekly Downloads

1

Version

1.0.2

License

ISC

Unpacked Size

10.1 kB

Total Files

23

Last publish

Collaborators

  • rilexus