-
Notifications
You must be signed in to change notification settings - Fork 49.6k
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'm not sure if question or bug.
I upgraded to the latest version of eslint-plugin-react-hooks
, enabled every compiler lint rule, and got 150+ errors in a reasonably sized codebase related to react-hooks/preserve-manual-memoization
. The attached playground link comes from a smaller project with idiomatic React/Relay code where I saw similar issues.
I roughly understand that the compiler can do a little bit better than me in this example, but I still prefer writing useCallback
/useMemo
in case I need to disable the compiler. I prefer manual control over memoization, and deferring "the rest" to the compiler. I realize that's subjective, so this is more of a question of whether this rule will be on by default in the recommended config in eslint-plugin-react-hooks
? If yes, will it be a warning or an error?
Depending on the answer, I would like to ask if it's possible to change the name, title and explanation of this lint rule to something more approachable. Right now it says:
react-hooks/preserve-manual-memoization
Compilation Skipped: Existing memoization could not be preserved
React Compiler has skipped optimizing this component because the existing manual memoization could not be preserved. This value was memoized in source but not in compilation output.
The wording is imho quite confusing. The compiler is telling me I did something wrong, and is giving me no hints about what that might be. How about this:
react-hooks/unnecessary-manual-memoization
Compilation Skipped: Unnecessary manual memoization
React Compiler has skipped optimizing this component because the manual memoization is weaker than React Compiler's memoization. Remove theuseMemo
call and embed the result directly in your render function.
My final question is: if you can detect that React Compiler can do a better than me, couldn't you wrap my memoization with some compiler magic and get rid of this lint rule?
How often does this bug happen?
Every time
What version of React are you using?
19.2.0.
What version of React Compiler are you using?
I don't know, latest.