1.0.2 • Published 2 years ago

react-hook-event v1.0.2

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

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>
}