-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
react/no-direct-mutation-state doesn't catch all cases #1418
Comments
I think we figured this out yesterday. Somebody created a PR for not allowing mutation for |
is there any news on this? or alternatives that i could use? |
@meldafert I just found out the other day about this rule not catching all cases. Ended up marking state immutable via Flow instead, which is perfect for this job: // ...
type State = $ReadOnly<{| ... |}>
class Smth extends Component<Props, State> {
// ...
} |
@kangax thank you, this is exactly what i needed. (turns out typescript has this too). |
@meldafert lint rule pending gajus/eslint-plugin-flowtype#400 |
@meldafert TypeScript already disallows changing props as they are marked as readonly through typescript typing already (the app will not build if you try to mutate props) |
@maniator True, but only for mutating this.props itself, but not for eg. |
@meldafert ahh, so it does not do a deap check. You can probably also do (in ts) readonly list: Item[], |
In this case eslint won't show any errors.
The text was updated successfully, but these errors were encountered: