-
Notifications
You must be signed in to change notification settings - Fork 50.2k
Open
Labels
Status: UnconfirmedA potential issue that we haven't yet confirmed as a bugA potential issue that we haven't yet confirmed as a bugType: Bug
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-hooks (build issue installing or using the eslint plugin)
- react-compiler-healthcheck (build issue installing or using the healthcheck script)
Link to repro
Repro steps
Calling setState in useEffect is marked as an error per react-hooks/set-state-in-effect lint:
const [, setState] = useState('');
useEffect(() => {
// marked as react-hooks/set-state-in-effect error
setState('test');
}, []);However there is no lint error if the setState is wrapped in an useEffectEvent:
const onSetState = useEffectEvent(() => {
setState('test');
});
useEffect(() => {
// lint passes
onSetState();
});This provides an easy escape hatch for developers who want to bypass the lint rule.
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?
No compiler needed. eslint-plugin-react-hooks is 7.0.1
Metadata
Metadata
Assignees
Labels
Status: UnconfirmedA potential issue that we haven't yet confirmed as a bugA potential issue that we haven't yet confirmed as a bugType: Bug