Data that changes.
WHAT STATE IS
Data determining what the interface shows.
WHAT KINDS EXIST
- Local: belonging to one component
- Shared: needed by several
- Server data: fetched, cached and possibly stale
- Address state: reflected in the address bar
WHY THAT LAST ONE MATTERS
State in the address can be shared, bookmarked and returned to.
WHAT TO KEEP LOCAL
Anything only one component needs.
WHY
Lifting everything to a shared store makes the application harder to reason about.
WHAT TO SHARE
Only what genuinely needs sharing.
WHAT TO TREAT DIFFERENTLY
Server data, which is a cache rather than state you own.
WHAT THAT IMPLIES
It can be stale, and needs invalidation and refetching.
WHAT TO AVOID
Duplicating the same data in several places Deriving values and storing them, rather than computing them State nobody can trace the origin of
WHAT TO PREFER
A single source for each piece of data.
WHAT TO CHECK
Whether the interface can be reconstructed from the state alone.