question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:open
  • Created 6 years ago
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
jseminckcommented, Sep 8, 2017

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 to no-direct-mutation-state rule as well.

https://github.com/yannickcr/eslint-plugin-react/pull/1416

0reactions
maniatorcommented, May 3, 2019

@meldafert ahh, so it does not do a deap check.

You can probably also do (in ts)

readonly list: Item[],
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found