Skip to content

Instantly share code, notes, and snippets.

@crrobinson14
Created March 11, 2025 14:06
Show Gist options
  • Select an option

  • Save crrobinson14/03d62ccceb63b294206863672e3f7747 to your computer and use it in GitHub Desktop.

Select an option

Save crrobinson14/03d62ccceb63b294206863672e3f7747 to your computer and use it in GitHub Desktop.
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