Skip to content
New issue

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

New rule suggestion: no-access-state-in-setstate #172

Closed
zerkms opened this issue Jul 16, 2018 · 6 comments
Closed

New rule suggestion: no-access-state-in-setstate #172

zerkms opened this issue Jul 16, 2018 · 6 comments

Comments

@zerkms
Copy link

zerkms commented Jul 16, 2018

This is the same as https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-access-state-in-setstate.md

The purpose: to deny using this.state inside this.setState call.

Why: Given this.setState mutates the state asynchronously it's extremely easy to introduce a subtle bug when in 2 sequential calls one relies on a particular this.state state. And if those this.setState calls are in different functions and spatially not even close the problem might be really challenging to debug.

@karfau
Copy link

karfau commented Jan 16, 2019

In #80 it was suggested for this rule to have an option for only allowing the functional way of setting state instead of making this a standalone rule. this option could allow for quite a performance boost in detecting failing cases.

@cheeZery
Copy link
Contributor

cheeZery commented Jan 16, 2019

Oh my, I already submitted a PR (#190) for this a while ago but somehow managed to link the wrong issue back then.. changed that now :)

@karfau
Copy link

karfau commented Mar 19, 2019

Since #190 was reverted in #211 this issue has not been fixed.

@adidahiya adidahiya reopened this Mar 19, 2019
@cheeZery
Copy link
Contributor

cheeZery commented Apr 8, 2019

In case your wondering about the progress of this issue: I started working on the typed rule but ran into some problems and now need a bit of help, #190 (comment) :-) Feel free to share your knowledge ♥

@adidahiya
Copy link
Contributor

This suggestion is still a good idea, but it should be migrated to an eslint rule. See #210

@karfau
Copy link

karfau commented Aug 22, 2019

no need to migrate it, the idea came from an eslint rule, see description

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants