Course contentsShow
← React
Lesson 1464 of 2,39636. Concurrent ReactFree lesson

Heavy Computation Example: Large Lists

See how filtering or sorting thousands of items in render creates blocking work that benefits from deferral.

Heavy Computation Example: Large Lists

You'll learn how filtering or sorting thousands of list items directly in render creates blocking work that freezes the UI—and why this scenario is perfect for useTransition or useDeferredValue.

The Problem: Lists That Block

Imagine you have 5,000 items and a search box. Every keystroke triggers a filter operation that loops through all 5,000 items, checks each one, and builds a new array. If this happens synchronously in render, React must finish the entire computation before the browser can update the screen—including showing the letter you just typed.

Result: The input feels sluggish. Users type "hello" but see "he" pause "hel" pause "hell" pause "hello". It's janky.

Why Lists Are Expensive

const filteredItems = allItems.filter(item => 
  item.name.toLowerCase().includes(searchTerm.toLowerCase())
);

If allItems.length is 10,000, this filter runs 10,000 comparisons every render. Add sorting or complex matching logic, and you easily exceed that 50ms threshold where humans notice lag.

The Concurrent Solution

This is exactly what transitions were designed for. You keep the input responsive (urgent update) while letting the heavy filter run as low-priority work (transition update). React can interrupt the filtering to handle the next keystroke, preventing the UI freeze.

Without concurrent features, your only option was debouncing—which adds artificial delay. With useTransition or useDeferredValue, React handles the prioritization for you, keeping the input snappy while the list updates in the background.

Key Takeaway: Filtering or sorting large arrays in render creates blocking computations; concurrent features let React prioritize user input over heavy list updates, eliminating jank without debounce delays.