reactjs / reactjs/react.dev

It may allow beginners to taste the sweetness of not following the rules

Open
#8,230 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Summary

https://react.dev/learn/queueing-a-series-of-state-updates

The first challenge in this chapter can still work normally even if it is written like this, because it relies on click behavior

async function handleClick() {
    setPending(pending + 1);
    await delay(3000);
    setPending(pending=>pending - 1);
    setCompleted(completed=>completed + 1);
  }

However, if it is changed to this, it will not work. At this point, we must change setPending(pending + 1) to setPending(pending => pending + 1)

async function handleClick() {
    setTimeout(()=> {setPending(pending + 1);}, 1000)
    await delay(3000);
    setPending(pending=>pending - 1);
    setCompleted(completed=>completed + 1);
  }
Page

https://react.dev/learn/queueing-a-series-of-state-updates

Details

Perhaps some annotations could be added

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 with the linked queueing-a-series-of-state-updates page and review the first challenge and its state-update examples. Reproduce the delayed setTimeout variant described in the issue, then determine where an annotation should explain the functional updater form. Done means the page clearly warns about this case and the challenge remains understandable.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.