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-effect in your eslint config
- Import React with
import * as React from 'react'
- Create a component that calls
setState from inside React.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'.
When calling
setStatefrom insideReact.useEffect, as opposed to directlyuseEffect, theset-state-in-effecteslint rule does not detect a violation. This rule should detect violations regardless of howuseStateanduseEffectare imported.React version: 19.2.3
eslint-plugin-react-hooksversion: 7.0.1Steps To Reproduce
set-state-in-effectin your eslint configimport * as React from 'react'setStatefrom insideReact.useEffectLink to code example: https://github.com/appellation/eslint-react-repro
The current behavior
set-state-in-effectonly detects violations when directly importinguseStateanduseEffect. It does not detect violations when usingReact.useStateandReact.useEffectfromimport * as React from 'react'.The expected behavior
set-state-in-effectshould detect violations when usingReact.useStateandReact.useEffectfromimport * as React from 'react'.