You’ve written this counter a hundred times. Click +1, it shows 1. But the function that shows it is called again from scratch every render. So where was the 1 between calls? Step through it and find out.

source · Counter.tsx
1function Counter() {
2 let count = 0
3 return <button onClick={() => { count++; rerender() }}>{count}</button>
4}
runs of Counter()

nothing yet: the function hasn’t run

output
count
render 1 · first render

Step through the first render. Where is count kept?