React Native error: Raw “ ” must be wrapped in an explicit Component

前端 未结 6 794
执笔经年
执笔经年 2021-01-19 14:27

Hi, I am having this error in react native and cannot figure out what is causing it. Help would be greatly appreciated.

Thank you

6条回答
  •  我在风中等你
    2021-01-19 14:52

    I encountered a similar error when checking whether to render a component in the following manner:

    {somevariable && abcd}
    

    Whenever somevariable was 0, that somevariable would be interpreted as something that was supposed to be rendered and thus 0 is an invalid React Element. To resolve this, I made sure that the first expression always evaluated to a boolean.

    {!!somevariable && abcd}
    

提交回复
热议问题