State in React
Reactโs documentation provides some good examples of what is and isnโt state:
- Does it remain unchanged over time? If so, it isnโt state.
- Is it passed in from a parent via props? If so, it isnโt state.
- Can you compute it based on existing state or props in your component? If so, it definitely isnโt state!
Whatโs left is probably state.
State is different than props. Props are passed from the parent to the child to customize how the component looks or functions. State acts as the componentโs memory.