reactjs / reactjs/react.dev

[Bug]: 'Fix debouncing ' solution doesn't work

Open
#8,096 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug: unconfirmed
Dominant language
JavaScript
Stars
11.8k
Forks
7.9k
Avg merge
1d 11h
Merged PRs (30d)
11

Description

Summary

https://react.dev/learn/referencing-values-with-refs#fix-debouncing --> Solution --> Try provided solution: Only the last button handler fires after debouncing.

Page

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

Details

https://react.dev/learn/referencing-values-with-refs#fix-debouncing --> Solution --> Try provided solution: Only the last button handler fires after debouncing.

The solution via using useRef doesn't work and has the same issue as in the challenge description: "This example works, but not quite as intended. The buttons are not independent. To see the problem, click one of the buttons, and then immediately click another button. You’d expect that after a delay, you would see both button’s messages. But only the last button’s message shows up. The first button’s message gets lost."

Only the last button handler fires after debouncing.

Checked on:
Win11, Chrome Version 141.0.7390.123 (Official Build) (64-bit)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the linked “Fix debouncing” section in the React documentation and reproduce the example by clicking two buttons in quick succession. Trace the provided solution and verify that the buttons debounce independently; it is done when both delayed messages appear rather than only the last one.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react
Domain
documentation
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.