Skip to content
RED SAGSkills
medium10 pts · first answer countsreact-hooks

Ref value not shown on screen

Clicking the button never updates the number on screen. Why?

function Clicks() {
  const clicks = useRef(0)
  return (
    <button onClick={() => { clicks.current += 1 }}>
      Clicked {clicks.current} times
    </button>
  )
}
Choose one answer

Discussion 0

Join free to post in the discussion.

Related questions