useWorker
Run a pure function in a Web Worker so heavy computation does not freeze the page. The function is sent as source text, so it must be self-contained: no closures, imports or variables from outside its body, and its arguments and result must be structured-cloneable.
- Level
- Advanced
- Since
- v2.1.0
import {useWorker} from '@zenuilabs/react-hooks';Loading demo_
More in Performance
PerformanceBasicuseDebounceReturn a copy of a value that only updates after it has stopped changing for a set time. Use it to wait for the user to pause before searching or saving.PerformanceIntermediateuseDebouncedCallbackWrap a function so it only runs after calls stop for a given delay. Use it for search inputs, autosave and resize handlers.PerformanceIntermediateuseThrottleReturn a copy of a fast-changing value that updates at most once per interval. Use it for scroll positions, pointer coordinates and other values that change many times a second.