File tree Expand file tree Collapse file tree
packages/babel-plugin-component-annotate Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -187,7 +187,7 @@ function createJSXProcessingContext(
187187 fragmentContext : state . sentryFragmentContext ,
188188 autoInjectSentryLabel : ! ! state . opts . autoInjectSentryLabel ,
189189 textComponentNames :
190- ( typeof state . opts . autoInjectSentryLabel === "object"
190+ ( state . opts . autoInjectSentryLabel && typeof state . opts . autoInjectSentryLabel === "object"
191191 ? state . opts . autoInjectSentryLabel . textComponentNames
192192 : undefined ) ?? DEFAULT_TEXT_COMPONENT_NAMES ,
193193 } ;
@@ -790,7 +790,6 @@ function extractTextFromTextComponent(
790790 if ( innerTexts === null ) {
791791 return null ;
792792 }
793- texts . push ( ...innerTexts ) ;
794793 }
795794 } else if ( t . isJSXFragment ( child ) ) {
796795 const innerTexts = extractTextFromTextComponent ( t , child , textComponentNames ) ;
Original file line number Diff line number Diff line change @@ -571,20 +571,20 @@ describe("autoInjectSentryLabel", () => {
571571 expect ( result ?. code ) . toContain ( '"sentry-label": "Hello World more"' ) ;
572572 } ) ;
573573
574- it ( "extracts text from non-text wrapper inside Text " , ( ) => {
574+ it ( "handles Text wrapping only a non-text element " , ( ) => {
575575 const result = transformWith ( `
576576 import React from 'react';
577577 import { Text, View } from 'react-native';
578578
579579 export default function MyComponent() {
580580 return (
581581 <View>
582- <Text>Hello <Bold>world </Bold></Text>
582+ <Text><Bold>hello </Bold></Text>
583583 </View>
584584 );
585585 }
586586 ` ) ;
587- expect ( result ?. code ) . toContain ( ' "sentry-label": "Hello world"' ) ;
587+ expect ( result ?. code ) . not . toContain ( "sentry-label" ) ;
588588 } ) ;
589589 } ) ;
590590
You can’t perform that action at this time.
0 commit comments