react-custom-events-hooks
About
Create custom events. Fast, simple, fun
Alternatives
- react-custom-events-hooks by Harsh Rohila
- @use-it/event-listener by Donavon West
- react-event-hooks by Silvester Wilson Wennekers
How to Install
First, install the library in your project by npm:
$ npm install react-custom-events-hooks
Or Yarn:
$ yarn add react-custom-events-hooks
Getting Started
• Import hooks in React application file:
;
Returned Values
Example
;; /* ------ Emit + Listen Example ------ */ const EmitListenExample = { const message setMessage = ; const callMyEvent = ; return <> <p>message</p> <button onClick= > Say Hello! </button> </> ;}; /* ------ Only Emit Example 1 ------ */ const EmitExample = { const callMyEvent = ; return <> <button onClick= > Say Hello! </button> </> ;}; /* ------ Only Emit Example 2 ------ */ const EmitExample = { const callMyEvent = ; return <> <button onClick= > Say Hello! </button> </> ;}; /* ------ Only Listen Example 1 ------ */ const ListenExample = { const message setMessage = ; ; return <> <p>message</p> </> ;}; /* ------ Only Listen Example 2 ------ */ const ListenExample = { const message setMessage = ; ; return <> <p>message</p> </> ;};
License
This project is licensed under the MIT License © 2020-present Jakub Biesiada