creativetimofficial/soft-ui-react-native

Objects are not valid as a react Child error

davvit opened this issue · 4 comments

Im facing the following issue on Text component. The error is Objects are not valid as React Child....
and its because of how the children prop is rendered in that controller. Its seems fine to me but not sure why its throwing error. Hoping someone can find the issue here.

Text.js

  <Text {...textID} {...rest} style={textStyles}>
      {children}  
    </Text>

I have tried {props.children} here but same result. {JSON.stringify(props.children)} renders the strings with quotes around them so i know the text is coming through.

On the second image(using {JSON.stringify(props.children)} ) , You can see the brand text is actually an object hence the error. Is the brand name usage of the control wrong or is there some other issue here?

Screenshot_20211223-003910_Expo Go

Screenshot_20211223-004816_Expo Go

@davvit this issue was automatically closed because it did not follow our rules:

IMPORTANT: Please use the following link to create a new issue:

https://www.creative-tim.com/new-issue/soft-ui-react-native

**If your issue was not created using the app above, it will be closed immediately.**



Love Creative Tim? Do you need Angular, React, Vuejs or HTML? You can visit:
👉  https://www.creative-tim.com/bundles
👉  https://www.creative-tim.com


@davvit From what I see all the texts are rendered with " "

  • Have you done any updates to your project?
  • Is it working ok when on your initial setup?

I am in a JS project so I converted the control to JS version..(removed types etc).
The quote is from doing JSON.stringify(children). For testing purposes ...to see what kind of object children is.

If I didnt do the JSON.stringify I get the 'objects are not valid as react child' error...

@hetmann this seems to solve the issue for now.

  <Text {...textID} {...rest} style={textStyles}>
      {typeof props.children === 'object'
        ? props.children.children
        : props.children}
    </Text>