Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Objects are not valid as a react Child error #8

Open
davvit opened this issue Dec 23, 2021 · 4 comments
Open

Objects are not valid as a react Child error #8

davvit opened this issue Dec 23, 2021 · 4 comments

Comments

@davvit
Copy link

davvit commented Dec 23, 2021

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

@github-actions
Copy link

@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


@hetmann hetmann reopened this Dec 23, 2021
@hetmann
Copy link
Contributor

hetmann commented Dec 23, 2021

@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?

@davvit
Copy link
Author

davvit commented Dec 24, 2021

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...

@davvit
Copy link
Author

davvit commented Dec 25, 2021

@hetmann this seems to solve the issue for now.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants