@@ -88,7 +88,7 @@ module.exports = {
8888 } ) ;
8989 }
9090
91- function findJSXElementOrFragment ( variables , name , previousReferences ) {
91+ function findJSXElementOrFragment ( startNode , name , previousReferences ) {
9292 function find ( refs , prevRefs ) {
9393 for ( let i = refs . length - 1 ; i >= 0 ; i -- ) {
9494 if ( has ( refs [ i ] , 'writeExpr' ) ) {
@@ -97,14 +97,14 @@ module.exports = {
9797 return ( jsxUtil . isJSX ( writeExpr )
9898 && writeExpr )
9999 || ( ( writeExpr && writeExpr . type === 'Identifier' )
100- && findJSXElementOrFragment ( variables , writeExpr . name , prevRefs ) ) ;
100+ && findJSXElementOrFragment ( startNode , writeExpr . name , prevRefs ) ) ;
101101 }
102102 }
103103
104104 return null ;
105105 }
106106
107- const variable = variableUtil . getVariable ( variables , name ) ;
107+ const variable = variableUtil . getVariableFromContext ( context , startNode , name ) ;
108108 if ( variable && variable . references ) {
109109 const containDuplicates = previousReferences . some ( ( ref ) => includes ( variable . references , ref ) ) ;
110110
@@ -150,8 +150,7 @@ module.exports = {
150150 return ;
151151 }
152152
153- const variables = variableUtil . variablesInScope ( context , node ) ;
154- const element = findJSXElementOrFragment ( variables , node . expression . name , [ ] ) ;
153+ const element = findJSXElementOrFragment ( node , node . expression . name , [ ] ) ;
155154
156155 if ( element ) {
157156 const baseDepth = getDepth ( node ) ;
0 commit comments