use-webworker
A react hook wrapper over webworker exposing message data from worker as state
👏 & ❤️ to auto badger for making badging simple
Install
npm install --save use-webworker
Usage
import useWebworker from 'use-webworker'
function Example {
const {isProcessing, data: dataFromWorker } = useWebworker({
url: '/worker.js', // available at %PUBLIC_URL%/worker.js
data: {}
});
if(isProcessing) {
return <h1>Loading...</h1>
}
return <h1>{dataFromWorker}</h1>
}
License
MIT © technikhil314