Training Grounds
Force Refresh Does NothingBlack Belt
+50 Ki
Description

A dashboard panel shows the time it was last refreshed. Clicking the Refresh button should update the timestamp. The button appears to do nothing - the timestamp never changes

Anomaly

The panel shows "Last refreshed: Never" on load. Clicking Refresh repeatedly has no effect - the timestamp never updates to the current time.

Constraint
The refreshKey state must change with each click - do not delete it
Hint

React doesn't always re-render when you call setState - when does it decide to skip?

Consult the SenseiOnly for those truly stuck · Flip to reveal

React doesn't always re-render when you call setState - when does it decide to skip?

Loading editor…
Correct Solution
Loading...

Why this fixes it

`setRefreshKey(refreshKey)` passed the current value of `refreshKey` back into state - React applies `Object.is` to compare the new value against the old one, and because they were identical primitives, it classified the update as a no-op and bailed out without re-rendering or re-running the effect. Changing the call to `setRefreshKey(prev => prev + 1)` produces a new integer on every click, one that is always different from the previous value. `Object.is(0, 1)` is `false`, so React proceeds with the re-render, the effect fires, and `setLastRefresh` updates the displayed timestamp.

Expected OutputGoal State
Your OutputLive