react-signal-slot
A simple way to trigger the functions of other components.
Install
npm i react-signal-slot
Usage
;; const A = { const text setText = ; const fn = ; ; // subscribe the signal of "signal" return <span>text</span> ;}; const B = { const inputEle = ; const signal = ; return <> <input ref=inputEle /> <button onClick= >Signal</button> </> ;};
API
const signal = ;;
This hook returns a function which can emit signal. The emit function can emit signal and params.
;
This hook will subscribe to the signal you want. When the signal is emitted, the "fn" will be triggered.
License
MIT