Skip to content

Commit eea8efe

Browse files
committed
Merge pull request airbnb#635 from lencioni/no-is-mounted
[eslint-config] [breaking] Enable react/no-is-mounted rule
2 parents 0af35c9 + f2dc504 commit eea8efe

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

packages/eslint-config-airbnb/rules/react.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ module.exports = {
4848
// Prevent usage of setState in componentDidUpdate
4949
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-did-update-set-state.md
5050
'react/no-did-update-set-state': [2, 'allow-in-func'],
51+
// Prevent usage of isMounted
52+
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-is-mounted.md
53+
'react/no-is-mounted': 2,
5154
// Prevent multiple component definition per file
5255
// https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-multi-comp.md
5356
'react/no-multi-comp': 2,

react/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
1. [Tags](#tags)
1616
1. [Methods](#methods)
1717
1. [Ordering](#ordering)
18+
1. [`isMounted`](#ismounted)
1819

1920
## Basic Rules
2021

@@ -334,4 +335,12 @@
334335
335336
eslint rules: [`react/sort-comp`](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/sort-comp.md).
336337
338+
## `isMounted`
339+
340+
[`isMounted` is an anti-pattern][anti-pattern], is not available when using ES6 classes, and is on its way to being officially deprecated. Its use should be avoided.
341+
342+
[anti-pattern]: https://facebook.github.io/react/blog/2015/12/16/ismounted-antipattern.html
343+
344+
eslint rules: [`react/no-is-mounted`](https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-is-mounted.md).
345+
337346
**[⬆ back to top](#table-of-contents)**

0 commit comments

Comments
 (0)