[Compiler Bug]: setState in useEffect / react compiler and eslint hooks plugin #31070
Open
1 of 4 tasks
Labels
Component: Optimizing Compiler
Status: Unconfirmed
A potential issue that we haven't yet confirmed as a bug
Type: Bug
What kind of issue is this?
Link to repro
https://playground.react.dev/#N4Igzg9grgTgxgUxALhAgHgBwjALgAgBMEAzAQygBsCSoA7OXASwjvwFkBPAQU0wApg+TGTBgEhAEql8AXwCU+YAB02+OKzAEA2rjIwA5glwAafONwAVfUdwBdfAF58UcQGU9uBPzpVK81VV8fAB6EPwEMEomOlwAWkImMDIAI0oEOLoMeOis-BgEMkY4jQBbTCZ0mBCCoviyiqqg0PDI3PjE5LSMrPQcmIR8wuKACwgIAGswEIwRii0mADcM4kwwZuk6gDpXBABREhIERn5+RUcAPiVm4KYSfH4RMQlpEi24WALY-ABCR2c9IZjIoVGpgsELNYgbhHqJxFJSO9PghYvIANw3OTNBQYujNDR0LRKcy4TjpMByJwucQABQgfAQMH4gNs6MCagKuFgbAAPIlFiSyZFHMAtEKwLILgAJBCUSgQfAAdRwlEIPJC-IuuNk7Iw2DwRFIFGo+FoDGYrA4PD4ACZBMI4S8ZAprmoCUTdDZjGZIV77FTdh4yF4fH4Ani1GbGCw2FBMIRgwgobYzq7wfg7g8nvDXkiYF8CH8AX6QZiIcZk8ZYc8EW8PvmUbg2WCsWodRHgptGDtxAcjidU5c0+C4wmvJWYc3gjj2cF3QQhGLyZTnLs6QymSzgbjmpzufg+UtBeSRUvIpKZXKFcqYKr1ZrtaoQLIgA
Repro steps
the eslint plugin react hook complains about calling setState in a useEffect:
more discussion here: #15329
I'm happy with the eslint error ;- it is potentially dangerous.
but the eslint-plugin-react-compiler errors if you disable the react hook rule ;- in this particular case this seems over the top.
Will it stop the react compiler compiling this file or its just a eslint extra warning?
In the 2nd example, I've abstracted the setState to another function and I get no errors. This is fine in the context of the eslint plugin but what about react compiler?
I was lead to believe a eslint compiler plugin warning means it will not be compiled and bail out, but I guess for warnings because of disabling eslint rules, this is not the case?
In my opinion:
How often does this bug happen?
Every time
What version of React are you using?
0.0.0-experimental-92aaa43-20240924
The text was updated successfully, but these errors were encountered: