react-hook-event
v1.0.2
Published
Utility hooks for event dispatching.
Downloads
2
Maintainers
Readme
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>
}