[Typo]: Code example mistake in useMemo page

Open Beginner friendly
#7,252 1 comment 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 React useMemo reference page at the “Preventing an Effect from firing too often” section and inspect the ChatRoom example. Confirm the stray createOptions line and the dependency comment, then verify the example is self-contained and the wording accurately describes the options object.

Written by the indexing model from the issue text.

Description

type: typos
Summary

There is a mistake in the ChatRoom example code on the useMemo page, specifically in the 'Preventing an Effect from firing too often' section.

Page

https://react.dev/reference/react/useMemo#preventing-an-effect-from-firing-too-often

Details

There are two mistakes in the ChatRoom example under the 'Preventing an Effect from firing too often' section:

  1. The line const options = createOptions() suddenly appears in the code without context. It seems like this should be removed.
  2. In the comment 'Only changes when createOptions changes', the reference to 'createOptions' should be replaced with 'options object'. This is because options is the actual dependency in the useEffect.

Screenshot of typo:
스크린샷 2024-10-24 오후 7 28 57

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.