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

push new page,how to hide TabNavigator, #63

Closed lidong1665 closed 8 years ago

lidong1665 commented 8 years ago

when I push a new page,how to hide TabNavigator,

magrinj commented 8 years ago

I'm not sure I have understand your question, but I try to answer, That depend how you implement your TabNavigator:

1- If you put your TabNavigator in a Navigator, you can do it, by using this Navigator to push your next views,

2 - If you put each one of your child view in a Navigator, you can try to set the height to 0, but I thing the first solution if the best for your question.

ide commented 8 years ago

@magrinj Thanks for answering! Both of those approaches sound good and I agree that solution 1 is better if it meets the needs of the app.

lidong1665 commented 8 years ago

Thank you very much. I'm very Sorry, my question is that click child view in a button push a new page,

ide commented 8 years ago

Somewhere in your app you probably have some code that looks like this:

<TabNavigator>
  <TabNavigator.Item
    selected={this.state.selectedTab === 'group'}
    ...>
    <GroupScreen />
  </TabNavigator.Item>
  <TabNavigator.Item
    selected={this.state.selectedTab === 'profile'}
    ...>
    <ProfileScreen />
  </TabNavigator.Item>
</TabNavigator>

You need to re-render the parent component using this.setState({ selectedTab: 'group' }).

The best way is to pass a callback into your component, and call this callback when the user taps the button:

<ProfileScreen onRegisterAccount={() => { this.setState({ selectedTab: 'group' }); }} />