[Typo]: Code example mistake in useMemo page
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 11.8k
- Forks
- 7.9k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 11
Description
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:
- The line
const options = createOptions()suddenly appears in the code without context. It seems like this should be removed. - 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:
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
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.
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