New: Intelligent Flashcards spaced-repetition decks for every topic, built to make things actually stick.
You keep a click count in countRef and run countRef.current++ on each click while rendering {countRef.current}. Why does the number on screen stay stuck?
countRef
countRef.current++
{countRef.current}
Reading current inside JSX gives a frozen snapshot that only refreshes after the next state update runs.
current
Refs reset to their initial value on each render, so the count is lost.
Updating a ref's current value never triggers a re-render, so the visible number won't change.