Created
March 11, 2025 14:06
-
-
Save crrobinson14/03d62ccceb63b294206863672e3f7747 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export const useCrudeEventWrapper = () => { | |
| const [someUiThing, setSomeUiThing] = useState(); | |
| useEffect(() => { | |
| const adapter = new MyAdapter(); | |
| adapter.on('somethinghappened', (event) => { | |
| setSomeUiThing(event.whatever); | |
| }); | |
| return () => adapter.off('somethinghappened'); // or however you unsub | |
| }); | |
| return {someUiThing}; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment