Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
liy-che opened this issue Mar 28, 2025 · 0 comments
Open

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

liy-che opened this issue Mar 28, 2025 · 0 comments

Comments

@liy-che
Copy link

liy-che commented Mar 28, 2025

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 liy-che changed the title [Suggestion]: [Suggestion]: Make clear why Ref was used in the solution Mar 28, 2025
@liy-che liy-che changed the title [Suggestion]: Make clear why Ref was used in the solution [Suggestion]: Make clear why Ref was used in the third solution Mar 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant