derived state

A value that can be calculated from existing props or state, so it should be computed during render instead of stored as separate state.

In more detail

Copying a filtered list into state with an Effect causes an extra render and can drift out of step. Writing const filteredItems = items.filter(...) in the component body keeps it correct in a single render; wrap it in useMemo only if the calculation is expensive.

Related terms

Taught in

References