react/no-direct-mutation-state doesn't catch all cases
See original GitHub issue const { model } = this.state;
model.rating = rate;
In this case eslint won’t show any errors.
Issue Analytics
- State:
- Created 6 years ago
- Comments:8 (1 by maintainers)
Top Results From Across the Web
react/no-direct-mutation-state doesn't catch all cases #1418
I think we figured this out yesterday. Somebody created a PR for not allowing mutation for this.props and added support for this case....
Read more >Why does React update when directly mutating state?
When you use setState method, it expects properties to update. But since you do not provide any property to setState, it will do...
Read more >How to accidentally mutate state. And why not to
When you learn about React and state you will often read this: "Don't mutate the state". This means you shouldn't change an object...
Read more >Mutations in Apollo Client - Apollo GraphQL Docs
A mutate function that you can call at any time to execute the mutation. Unlike useQuery , useMutation doesn't execute its operation automatically...
Read more >Handling State in React: Four Immutable Approaches to ...
setState batches work behind the scenes. This means a manual state mutation may be overridden when setState is processed. · If you declare...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I think we figured this out yesterday. Somebody created a PR for not allowing mutation for
this.props
and added support for this case. Once that PR is finished we’ll try to move all the logic over tono-direct-mutation-state
rule as well.https://github.com/yannickcr/eslint-plugin-react/pull/1416
@meldafert ahh, so it does not do a deap check.
You can probably also do (in ts)