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
- useEffect — The React hook for running side work, such as adding listeners or changing document.body, after a component renders.
- useMemo — The React hook that caches the result of a calculation between renders and recalculates only when its dependencies change.
- antipattern — A common way of solving a problem that looks reasonable but causes bugs or extra work.
Taught in
- Avoiding Effect Antipatterns: Derived State And Events — React 19 & Modern Component Architecture