A counter displays its value and a doubled version of it. Clicking Increment should update both numbers together. The doubled value never changes after the page loads.
Click Increment — Count goes up correctly but Doubled stays at 0 forever. The derived value is frozen at the initial value no matter how many times you click.
The effect that computes the doubled value only runs once on mount because count is missing from the dependency array. The better fix is to not store derived values in state at all — compute them inline during render.
The effect that computes the doubled value only runs once on mount because count is missing from the dependency array. The better fix is to not store derived values in state at all — compute them inline during render.