React HooksLesson 47Free preview
React useState
This lesson is part of React · All levels
Summary
UseState allows functional components to store data that persists between renders. You declare the pair as the state value and the setter function, then call the setter to trigger the rendering. For objects or arrays, always make a new copy when updating so that changes are detected by React.
Key points
- Written with const
- The setter call triggers the component rendering
- Immutably update objects and arrays
- The initial value is only used on the first render.
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.