reactjs / reactjs/react.dev

Clarification on useCallback function name on beta docs

Open
#5,079 4 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

In the react beta docs, useCallback api reference page gives the following example
image

I think the constant naming memoizedFn leads to some confusion on what useCallback does.
People tend to assume that useCallback actually memoizes the function but it does not do that. It returns the same instance of the function between re-renders.
An appropriate name of that variable should be originalFn.
I maybe wrong so please let me know if the above makes sense.

Big fan of the beta docs btw ❤️ , beautiful documentation and excellent examples!

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

Open the React beta docs useCallback API reference and inspect the example shown in the issue. Compare the variable name with the surrounding explanation of useCallback, then update the example if maintainers agree that the terminology is confusing and verify the rendered documentation example.

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.