use-worker-hook
v1.0.0
Published
<h1>useWorker</h1>
Downloads
3
Readme
run a function in a webworker and return the value to your component asynchronously
npm install use-worker-hook
import React, { useState, useEffect } from 'react';
import useWorker from 'use-worker-hook';
function add(a, b) {
return a+b;
}
export default function App({a, b}) {
const added = useWorker(add, 0, a); // this will run in a webworker
return <h1>added: {added}</h1>
}