File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -33,6 +33,19 @@ module.exports = {
33
33
}
34
34
}
35
35
36
+ function isThisSetStateCallback ( node ) {
37
+ if ( node . parent && node . parent . type === 'CallExpression' ) {
38
+ var callee = node . parent . callee ;
39
+ var isMatching = (
40
+ callee . type === 'MemberExpression' &&
41
+ callee . object . type === 'ThisExpression' &&
42
+ callee . property . name === 'setState' &&
43
+ node . parent . arguments [ 1 ] === node
44
+ )
45
+ return isMatching
46
+ }
47
+ }
48
+
36
49
function isThisState ( node ) {
37
50
var isMatching = (
38
51
node . type === 'MemberExpression' &&
@@ -79,7 +92,7 @@ module.exports = {
79
92
MemberExpression : function ( node ) {
80
93
if ( isThisProps ( node ) || isThisState ( node ) ) {
81
94
var ancestors = context . getAncestors ( )
82
- if ( ancestors . some ( isThisSetState ) ) {
95
+ if ( ancestors . some ( isThisSetState ) && ! ancestors . some ( isThisSetStateCallback ) ) {
83
96
var setStateUsage = ancestors . find ( isThisSetState )
84
97
setStateUsages . push ( setStateUsage ) ;
85
98
}
You can’t perform that action at this time.
0 commit comments