Skip to content

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

Open
@liy-che

Description

@liy-che

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions