ptomasroos / react-native-tab-navigator

A tab bar that switches between scenes, written in JS for cross-platform support
MIT License
2.4k stars 415 forks source link

Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object. Check the render method of TabNavigator #153

Closed devanshsadhotra closed 6 years ago

devanshsadhotra commented 7 years ago

  <TabNavigator.Item
    selected={this.state.selectedTab === 'home'}
    title="Home"
    renderIcon={() => <Image source={...} />}
    renderSelectedIcon={() => <Image source={...} />}
    badgeText="1"
    onPress={() => this.setState({ selectedTab: 'home' })}>
    {homeView}
  </TabNavigator.Item>
  <TabNavigator.Item
    selected={this.state.selectedTab === 'profile'}
    title="Profile"
    renderIcon={() => <Image source={...} />}
    renderSelectedIcon={() => <Image source={...} />}
    renderBadge={() => <CustomBadgeView />}
    onPress={() => this.setState({ selectedTab: 'profile' })}>
    {profileView}
  </TabNavigator.Item>
</TabNavigator>```

i am implementing as mentioned above , but it's showing me error as mentioned in heading . 
 Kindly help
devanshsadhotra commented 7 years ago

i just figured out , it's showing me issue in render Icon in both tab items. and when now i remove render Icon and render selected icon , its throwing me , this error : react children only expected to receive a single react element child

devanshsadhotra commented 7 years ago

Another thing !! i am not been able to view my component

devanshsadhotra commented 7 years ago

I am not been able to select tabs after clicking over those.

guilhermemello commented 7 years ago

Same message here :(

devanshsadhotra commented 7 years ago

i have faced 1 more issue, i am not been able to navigate from any of the tabs to other page. for eg. i have a name list in one of my tab. and after clicking on that name i need to go to the profile. but navigation is just not working

devanshsadhotra commented 7 years ago

Is there anyone from the community , who can help me solve these issues? @ptomasroos

vokhuyet commented 7 years ago

hey, change both {homeView}and {profileView} to {} and {} fixed for me

vokhuyet commented 7 years ago

<homeView /> and <profileView/>

vokhuyet commented 7 years ago

fixed for me

ptomasroos commented 7 years ago

I'm currently at vacation. Will check back when being home again to see if I can find the cause.

devanshsadhotra commented 7 years ago

@vokhuyet this was solved and then apparently more issues appeared

vokhuyet commented 7 years ago

What issue did you get ? @devanshsadhotra

vokhuyet commented 7 years ago

I can try to pass navigation prop to child view. Sorry my english is so bad .

ptomasroos commented 6 years ago

Will close since this issue is more than a year, feel free to a open a new if this is still a issue.