State
useState remembers a value, and the screen redraws when it changes
Key points
- Keep values that change in useState: const [count, setCount] = useState(0)
- To change the value, always use setCount(nextValue)
- When the value changes, React redraws the screen for you. No need to update the DOM yourself
Try it
- Change +1 to +10
- Add a −1 button (hint: setCount(count - 1))
- Add a reset button that goes back to 0 (hint: setCount(0))