A component tracks how many times a user has clicked a secret area. The click count is stored in a ref. The displayed count never updates.
Click the secret area repeatedly — the counter on screen stays at 0. The ref value is updating internally but the UI never reflects it.
Refs are mutable containers that do not trigger re-renders when changed. If you need a value to appear in the UI, it must live in state.
Refs are mutable containers that do not trigger re-renders when changed. If you need a value to appear in the UI, it must live in state.