facebook / react

The library for web and native user interfaces.
https://react.dev
MIT License
224.77k stars 45.84k forks source link

[Compiler Bug]: Constants or properties named `use*` trigger compiler errors re: hooks #29900

Open aaronmw opened 2 weeks ago

aaronmw commented 2 weeks ago

What kind of issue is this?

Link to repro

https://playground.react.dev/#N4Igzg9grgTgxgUxALhHCA7MAXABFMBAYQENCxcBeXAbQB0NdcByAcQgEsMBzXbCPgAsEuHBBgJmAGgZNmABQ5wA1l15QADkJGqAJmGmyWAdRLY4gtbgAqANWYMAugwbosebJbABJMAGUSADMEACEoPGpgIwJiMgQwZFojOQAjcKEOCkzcDAhsB0ZcZwwAXxcMBAAPDXE8XQRAkigAGzxAqAw4bA5MXABZAE8AQQ0NAAoASlwowolsWEYAHgA+ZOmY0nIAOgBbEnGNuKpl3DG1pkXdDgA3XGUEAcpgQ8IS1cKmT-XCTYQyj8+iwA9Fdru8vhMJv81sBPJlfAFgmFsFsXvFdvsxmjjqdzrhLjc7g8nmi3nimM8fnF-l8LiCbuDPpCafige9-iASkA

Repro steps

Try to reference an object or property with a name starting with use*. Seems it could at least narrow its scope to functions named use*?

How often does this bug happen?

Every time

What version of React are you using?

^19.0.0-rc-f994737d14-20240522

josephsavona commented 2 weeks ago

Thanks for posting. We could probably relax this, and not consider properties of potential hooks to be hooks unless they’re named that way.

thedarshanpgowda commented 2 weeks ago

i think just renaming useCases to just Cases will work as it doesnt cause any of the compile time errors.