[Compiler Bug]: Using useMemo with an sync function should not be reported, or should be able to be configured
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 251k
- Forks
- 51.4k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 53
Description
What kind of issue is this?
- React Compiler core (the JS output is incorrect, or your app works incorrectly after optimization)
- babel-plugin-react-compiler (build issue installing or using the Babel plugin)
- eslint-plugin-react-compiler (build issue installing or using the eslint plugin)
- react-compiler-healthcheck (build issue installing or using the healthcheck script)
Link to repro
Repro steps
I got the issue when running the react hooks plugin that seems to use the babel plugin under the hood now.
The issue is here:
https://github.com/facebook/react/blame/ea0c17b0952e2b866a1f0dd4b5ac28c7df9d8518/compiler/packages/babel-plugin-react-compiler/src/Validation/ValidateUseMemo.ts#L110-L123
It seems to be new with latest version of the eslint plugin (v7), but not sure why without a proper changelog.
IMO an async function is just a function returning a promise, and there's no reason a promise isn't a valid value to be memoized.
How often does this bug happen?
Every time
What version of React are you using?
19.2
What version of React Compiler are you using?
none
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
Reproduce the warning using the linked React Playground example, then inspect compiler/packages/babel-plugin-react-compiler/src/Validation/ValidateUseMemo.ts at lines 110-123. Determine whether async functions should be accepted by useMemo or whether this behavior needs configuration, and verify that the chosen behavior is covered by the relevant compiler or plugin tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- babel, javascript, react
- Domain
- compilers, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100