reactjs / react.dev

The React documentation website
https://react.dev/
Creative Commons Attribution 4.0 International
11.08k stars 7.56k forks source link

[Suggestion]: Make better use of ref in the last challenge of the docs #7236

Open Spoof14 opened 1 month ago

Spoof14 commented 1 month ago

Summary

Remove useless useState and simply use ref

Page

No response

Details

The docs in the 4th challenge suggest using both a useState and a ref for managing the value of a component when there is a delay. This is unnecesarry and we can simply use the ref. https://react.dev/learn/referencing-values-with-refs#challenges

Spoof14 commented 1 month ago

5485 https://github.com/reactjs/react.dev/pull/5485/files