Created
April 2, 2021 20:49
-
-
Save westwick/b74c35b89dc16fb0588125664004fc8f to your computer and use it in GitHub Desktop.
This file contains 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 SomeComponent = (props) => { | |
const [searchWorker, setSearchWorker] = useState(); | |
useEffect(() => { | |
setSearchWorker(new SearchWorker()); | |
// 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