Grokking React Fundamentals
0% completed
Local and Global State
Where should a piece of state live? The answer decides which components can read the state, which can change it, and which components React renders again when it changes. The rule is short: put state in the component that uses it, and when several components need the same state, put it in their closest common parent.
Local State
State that only one component uses, and that it keeps to itself, is called local state. The count in the counter from the first lesson of this chapter is local state, because only Counter reads or changes it.
The following `App
.....
.....
.....
Like the course? Get enrolled and start learning!
Reading Progress
0%