reactjs / reactjs/react.dev

[Typo]: using function before creating it in example

Open Beginner friendly
#7,283 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Summary

The code example on "How does React know which state to return?" Deep Dive section in the "State: A Component's Memory" page is using the setState function before defining it. While this code would work due to function hoisting in javascript, it's generally is not recommended, especially as it disturbs the reading flow for code snippets.

Page

https://react.dev/learn/state-a-components-memory#how-does-react-know-which-state-to-return

Details

No response

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

Open the linked “State: A Component's Memory” page at the “How does React know which state to return?” Deep Dive section and inspect its code example. Reorder the example so setState is defined before it is used, then verify that the snippet remains correct and reads in the intended order.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react
Domain
documentation
Issue type
Documentation
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
65/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.