Derived state is any value you can compute from existing state rather than store separately. The principle: if you can calculate it, don't store it — derive it on each render. Storing derivable values invites them to get out of sync.
The anti-pattern: storing what you can compute
() {
[items, setItems] = ([]);
[total, setTotal] = ();
() {
([...items, item]);
(total + item.);
}
}
