[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.

Assessment

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

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.

Description

type: typos
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

Dominant language
JavaScript
Stars
11.8k
Forks
7.9k
Avg merge
16h 6m
Merged PRs (30d)
7

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.

More from reactjs/react.dev

All issues in reactjs/react.dev

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.