Unable to disable the react/no-did-mount-set-state check
See original GitHub issueI have the following code:
const elementHeight = isNaN(this.trElement.clientHeight) ? 0 : this.trElement.clientHeight;
const elementWidth = isNaN(this.trElement.clientWidth) ? 0 : this.trElement.clientWidth;
const firstItem = this.firstItem || this.parenNameEle;
const firstItemWidth = isNaN(firstItem.clientWidth) ? 0 : firstItem.clientWidth;
this.setState({ elementWidth, elementHeight, firstItemWidth });
}
When I run the eslint-plugin-react over this code I get the following error:
71:5 error Do not use setState in componentDidMount react/no-did-mount-set-state
That is working as expected. If I then add this line right before calling this.setState
the error goes away:
/* eslint-disable react/no-did-mount-set-state */
However, I am unable to disable this rule in my .eslintrc
file. When I try the following:
"rules": {
"react/no-did-mount-set-state": 0,
The error still happens when I run eslint. I would expect adding this to my .eslintrc file would stop that check.
Issue Analytics
- State:
- Created 6 years ago
- Comments:16 (8 by maintainers)
Top Results From Across the Web
Unable to disable the react/no-did-mount-set-state check #1711
I have the following code: const elementHeight = isNaN(this.trElement.clientHeight) ? 0 : this.trElement.clientHeight; const elementWidth ...
Read more >Can't perform a React state update on an unmounted ...
I am writing an application in React and was unable to avoid a super common pitfall, which is calling setState(...) after componentWillUnmount(.
Read more >React: Stop checking if your component is mounted - Medium
This article will provide solutions to the “Can't perform a React state update on an unmounted component” warning and why a call to...
Read more >Prevent React setState on unmounted Component
How to avoid the React warning: Can only update a mounted or mounting component. It usually means you have called setState on an...
Read more >Optimizing Performance - React
For a more detailed walkthrough, check out this article by Ben Schwarz. ... returned false for the subtree rooted at C2, React did...
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
Groan. You were totally right. I had a bunch of then in my node_modules files so I didn’t see that there was one in the src directory. When I change it there it works. I feel more than a little silly now. Thank you very much for all of your help and time.
I’m asking if there could be other eslint config files (theres multiple supported file names) that are affecting the settings.