[Compiler Bug]: Should support hooks named with symbols: use$, use_
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
https://github.com/vladmiller/legend-state-react-compiler-bug
Repro steps
isHookName checks for valid hook names and requires alphanumeric names. I believe it should also support $ and _ since those are valid characters in JavaScript function names.
In Legend State we have a hook named use$ to consume observables, which I had thought would be compatible with Compiler. So this is currently breaking Legend State with the Compiler enabled. See issue: https://github.com/LegendApp/legend-state/issues/477
I think the isHookName regexp should be changed to this to match valid function names in JavaScript.
/^use[A-Z0-9_$]*$/
Thanks 🙏
How often does this bug happen?
Every time
What version of React are you using?
19.0.0
What version of React Compiler are you using?
19.0.0-beta-e1e972c-20250221
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
Start in compiler/packages/babel-plugin-react-compiler/src/HIR/Environment.ts at isHookName, then reproduce the issue with the linked Legend State example. Check how hook names containing $ and _ are classified and verify that the compiler handles use$ and use_ correctly without breaking existing hook-name behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, react
- Domain
- compilers, frontend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 52/100