How to use the react-hooks-worker.useWorker function in react-hooks-worker

To help you get started, we’ve selected a few react-hooks-worker examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dai-shi / react-hooks-worker / examples / 04_inline / src / CalcFib.tsx View on Github external
const CalcFib: React.FC<{ count: number }> = ({ count }) => {
  const { result, error } = useWorker(createWorker, count);
  if (error) return <div>Error: {error}</div>;
  return <div>Result: {result}</div>;
};
github dai-shi / react-hooks-worker / examples / 03_comparison / src / CalcFib.tsx View on Github external
const CalcFib: React.FC&lt;{ count: number }&gt; = ({ count }) =&gt; {
  const { result, error } = useWorker('./slow_fib.js', count);
  if (error) return <div>Error: {error}</div>;
  return <div>Result: {result}</div>;
};
github dai-shi / react-hooks-worker / examples / 05_generator / src / CalcFib.tsx View on Github external
const CalcFib: React.FC&lt;{ count: number }&gt; = ({ count }) =&gt; {
  const { result, error } = useWorker(createWorker, count);
  if (error) return <div>Error: {error}</div>;
  return <div>Result: {result}</div>;
};
github dai-shi / react-hooks-worker / examples / 01_minimal / src / index.js View on Github external
const CalcFib = ({ count }) =&gt; {
  const { result, error } = useWorker(createWorker, count);
  if (error) return <div>Error: {error}</div>;
  return <div>Result: {result}</div>;
};

react-hooks-worker

React custom hooks for web workers

MIT
Latest version published 3 years ago

Package Health Score

45 / 100
Full package analysis