← React Field Guide
Concept 5 of 11
State
✦ Tap any highlighted term to learn more
is data that belongs to a and can change over time. When changes, React automatically that with the new data — you never manually update the .
You create with the . It returns two things: the current value, and a to update it. By convention, they're named [something, setSomething].
You must always use the setter — never modify directly. Doing my.push(item) or count = count + 1 won't trigger a . setCount(count + 1) will.
is private to the that owns it. If two need to share , you lift it up to their nearest common parent and pass it down as .