useDeferredValue for Input Debouncing
Delay re-renders of slow parts of the UI while keeping input snappy.
Welcome
In this lesson you will use useDeferredValue to delay re-rendering of expensive parts of the UI while keeping controlled inputs snappy and responsive.
What Is useDeferredValue?
useDeferredValue accepts a value and returns a deferred version of it. The deferred value lags behind the current value during urgent renders, allowing React to update the UI in two steps: fast for input, deferred for expensive output.
const [query, setQuery] = useState('');
const deferredQuery = useDeferredValue(query);
// query updates immediately on keystroke
// deferredQuery updates when React has capacityAll lessons in this course
- Racing Conditions & Effect Cleanup
- useTransition for Non-Blocking UI Updates
- useDeferredValue for Input Debouncing
- Suspense for Data & Code Boundaries