@@ -88,7 +88,7 @@ module.exports = {
88
88
} ) ;
89
89
}
90
90
91
- function findJSXElementOrFragment ( variables , name , previousReferences ) {
91
+ function findJSXElementOrFragment ( startNode , name , previousReferences ) {
92
92
function find ( refs , prevRefs ) {
93
93
for ( let i = refs . length - 1 ; i >= 0 ; i -- ) {
94
94
if ( has ( refs [ i ] , 'writeExpr' ) ) {
@@ -97,14 +97,14 @@ module.exports = {
97
97
return ( jsxUtil . isJSX ( writeExpr )
98
98
&& writeExpr )
99
99
|| ( ( writeExpr && writeExpr . type === 'Identifier' )
100
- && findJSXElementOrFragment ( variables , writeExpr . name , prevRefs ) ) ;
100
+ && findJSXElementOrFragment ( startNode , writeExpr . name , prevRefs ) ) ;
101
101
}
102
102
}
103
103
104
104
return null ;
105
105
}
106
106
107
- const variable = variableUtil . getVariable ( variables , name ) ;
107
+ const variable = variableUtil . getVariableFromContext ( context , startNode , name ) ;
108
108
if ( variable && variable . references ) {
109
109
const containDuplicates = previousReferences . some ( ( ref ) => includes ( variable . references , ref ) ) ;
110
110
@@ -150,8 +150,7 @@ module.exports = {
150
150
return ;
151
151
}
152
152
153
- const variables = variableUtil . variablesInScope ( context , node ) ;
154
- const element = findJSXElementOrFragment ( variables , node . expression . name , [ ] ) ;
153
+ const element = findJSXElementOrFragment ( node , node . expression . name , [ ] ) ;
155
154
156
155
if ( element ) {
157
156
const baseDepth = getDepth ( node ) ;
0 commit comments