yarn install && yarn start
Open State example subpage.
The main way to pass data between React components is to use props which are immutable. In order to have data that changes, state must be used.
Mutable state and how applications react to mutations is generally hard to understand. Therefore React limits the usage of state to a single Component. No other Components can read or change the state of other Components.
State can be initialized in the class constructor or using the useState hook
Build on top of the props example.
- App has local state now - a list of comments that grows every 3 seconds.
- CommentList has been upgraded to take a list of comment objects as props.