Skip to content

Instantly share code, notes, and snippets.

@westwick
Last active April 2, 2021 20:44
Show Gist options
  • Save westwick/a8ccfb4dd335c3807501a9dfc0ef1d3f to your computer and use it in GitHub Desktop.
Save westwick/a8ccfb4dd335c3807501a9dfc0ef1d3f to your computer and use it in GitHub Desktop.
const searchWorker = new SearchWorker();
export const SomeComponent = (props) => {
useEffect(() => {
// subscribe to worker messages
searchWorker.onmessage(...);
// do something with the worker on component init
searchWorker.postMessage(...);
}, []);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment