Skip to content

Commit a2f8a35

Browse files
yoyo837ljharb
authored andcommitted
[Fix] no-unused-class-component-methods: add getChildContext lifecycle method
Fixes #3135
1 parent 87fe152 commit a2f8a35

File tree

3 files changed

+5
-0
lines changed

3 files changed

+5
-0
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ This change log adheres to standards from [Keep a CHANGELOG](http://keepachangel
77

88
### Fixed
99
* [`no-invalid-html-attribute`]: allow `link` `rel` to have `apple-touch-icon`, `mask-icon` ([#3132][] @ljharb)
10+
* [`no-unused-class-component-methods`]: add `getChildContext` lifecycle method ([#3136][] @yoyo837)
1011

12+
[#3136]: https://github.com/yannickcr/eslint-plugin-react/pull/3136
1113
[#3132]: https://github.com/yannickcr/eslint-plugin-react/issue/3132
1214

1315
## [7.27.0] - 2021.11.09

lib/rules/no-unused-class-component-methods.js

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const LIFECYCLE_METHODS = new Set([
2121
'componentWillReceiveProps',
2222
'componentWillUnmount',
2323
'componentWillUpdate',
24+
'getChildContext',
2425
'getSnapshotBeforeUpdate',
2526
'render',
2627
'shouldComponentUpdate',

tests/lib/rules/no-unused-class-component-methods.js

+2
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,7 @@ ruleTester.run('no-unused-class-component-methods', rule, {
438438
componentDidUpdate() {}
439439
componentDidCatch() {}
440440
componentWillUnmount() {}
441+
getChildContext() {}
441442
render() {
442443
return <SomeComponent />;
443444
}
@@ -467,6 +468,7 @@ ruleTester.run('no-unused-class-component-methods', rule, {
467468
componentDidUpdate() {},
468469
componentDidCatch() {},
469470
componentWillUnmount() {},
471+
getChildContext() {},
470472
render() {
471473
return <SomeComponent />;
472474
},

0 commit comments

Comments
 (0)