react.dev icon indicating copy to clipboard operation
react.dev copied to clipboard

[Suggestion]: Make clear why Ref was used in the third solution

Open liy-che opened this issue 9 months ago • 0 comments

Summary

The solution for the third challenge, "Fix debouncing," does not require a Ref. Moving the let timeoutID; to the top inside the DebouncedButton component will fix the debouncing. Either point this out in the explanation or make it re-render so the solution requires Ref.

Page

https://react.dev/learn/referencing-values-with-refs

Details

Since code example does not use State, there's no re-rendering, and so there's no need to use Ref to remember anything across re-renders. The page mentions that Refs are not used often; although future-proof, I think the example should only use Ref when necessary.

liy-che avatar Mar 28 '25 01:03 liy-che