We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
no-set-state-directly-in-use-effect
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Common bad practice:
const Comp = () => { const [data, setData] = useState(); useEffect(() => { setData(); }, []); }
Create a rule no-set-state-directly-in-use-effect to prevent set state directly in the top useEffect callback scope:
Invalid
Valid
const Comp = () => { const [data, setData] = useState(); useEffect(() => { fetch().then(() => setData()); }, []); }
const Comp = () => { const [data, setData] = useState(); useEffect(() => { (async () => { setData() })(); }, []); }
const Comp = () => { const [data, setData] = useState(); useEffect(() => { const onLoad = () => { setData(); }; }, []); }
No response
The text was updated successfully, but these errors were encountered:
feat: add rule 'no-set-state-in-use-effect', closes #628
848e932
e3229c1
No branches or pull requests
Describe the problem
Common bad practice:
Describe the solution you'd like
Create a rule
no-set-state-directly-in-use-effect
to prevent set state directly in the top useEffect callback scope:Invalid
Valid
Alternatives considered
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: