-
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 bug
Description
When calling setState from inside React.useEffect, as opposed to directly useEffect, the set-state-in-effect eslint rule does not detect a violation. This rule should detect violations regardless of how useState and useEffect are imported.
React version: 19.2.3
eslint-plugin-react-hooks version: 7.0.1
Steps To Reproduce
- Enable
set-state-in-effectin your eslint config - Import React with
import * as React from 'react' - Create a component that calls
setStatefrom insideReact.useEffect - Run eslint and observe that eslint does not fail
Link to code example: https://github.com/appellation/eslint-react-repro
The current behavior
set-state-in-effect only detects violations when directly importing useState and useEffect. It does not detect violations when using React.useState and React.useEffect from import * as React from 'react'.
The expected behavior
set-state-in-effect should detect violations when using React.useState and React.useEffect from import * as React from 'react'.
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 bug