reactjs / reactjs/react.dev

Misleading note in the tutorial

Open
#1,013 2 comments 1 reaction 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

This note from the tutorial: reactjs.org/tutorial/tutorial.html#functional-components

Note
When we modified the Square to be a functional component, we also changed onClick={() => this.props.onClick()} to a shorter onClick={props.onClick} (note the lack of parentheses on both sides). In a class, we used an arrow function to access the correct this value, but in a functional component we don’t need to worry about this.

The note seems to suggest that onClick={this.props.onClick} wouldn't work in a class component, but that's false.

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 functional-components section at reactjs.org/tutorial/tutorial.html#functional-components and review the quoted note alongside the class-component example. Revise the note so it does not imply that onClick={this.props.onClick} cannot work in a class component; done means the explanation is accurate and still clearly describes the shorter functional-component form.

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
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.