reactjs / reactjs/react.dev

Conflicting description on getSnapshotBeforeUpdate section on the React.Component page

Open
#1,137 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Page: https://reactjs.org/docs/react-component.html
Section: getSnapshotBeforeUpdate

The description after the code block reads

In the above examples, it is important to read the scrollHeight property in getSnapshotBeforeUpdate because there may be delays between “render” phase lifecycles (like render) and “commit” phase lifecycles (like getSnapshotBeforeUpdate and componentDidUpdate).

It is indicating that we should be reading the scrollHeight property in getSnapshotBeforeUpdate due to the delays between the "render" phase lifecycles and "commit" phases lifecycles. But getSnapshotBeforeUpdate is indicated as one of the "commit" phases lifecycle. Is that correct?

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

Read the getSnapshotBeforeUpdate section on the React.Component page at https://reactjs.org/docs/react-component.html, including the code block and the quoted explanation beneath it. Check whether the description correctly distinguishes render and commit phase lifecycles, then update the conflicting wording so the lifecycle timing is unambiguous.

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
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.