File tree Expand file tree Collapse file tree 1 file changed +21
-2
lines changed
packages/core/src/components Expand file tree Collapse file tree 1 file changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -6,15 +6,34 @@ type MarkdownProps = {
66 style ?: StyleProp < ViewStyle > ;
77} ;
88
9+ const childToString = ( child ?: React . ReactNode ) : string => {
10+ if (
11+ typeof child === "undefined" ||
12+ child === null ||
13+ typeof child === "boolean"
14+ ) {
15+ return "" ;
16+ }
17+
18+ if ( JSON . stringify ( child ) === "{}" ) {
19+ return "" ;
20+ }
21+
22+ return ( child as number | string ) . toString ( ) ;
23+ } ;
24+
925const Markdown : React . FC < React . PropsWithChildren < MarkdownProps > > = ( {
10- children,
26+ children : childrenProp ,
1127 style,
1228} ) => {
29+ const children = React . Children . toArray ( childrenProp ) ;
30+ const text = children . map ( childToString ) . join ( "" ) ;
31+
1332 return (
1433 //'body' style applies to all markdown components
1534 //@ts -ignore TS does not like the type of this named style for some reason
1635 < MarkdownComponent style = { { body : StyleSheet . flatten ( style ) } } >
17- { children }
36+ { text }
1837 </ MarkdownComponent >
1938 ) ;
2039} ;
You can’t perform that action at this time.
0 commit comments