I have component Home contains TabView.
2 child components : Showing & Coming are 2 Tab of component Home
Inside component Showing has a button
How to press this button, index of TabView in Home will change to 1 (move to Coming tab)
Thank you !
First - please make sure you fill out the _issue template_ before you post an issue here. The maintainer is not likely going to entertain your question without it.
Secondly, if I am understanding your question correctly - you mean to ask how do you want to navigate from one screen to the other? If not, the solution below might not be relevant to you.
The navigation object whose index property matches with index attribute in the _navigation state_ is rendered.
So for example, if your navigation state looks something like this:
state = {
index: 0,
routes: [
{ index: 0, text: 'Showing' },
{ index: 1, text: 'Coming' },
]
}
Then in both the views which will have the button to navigate/switch tabs you can just update the index prop in the state object:
handleIndexChange = index => this.setState({ index });
and your button in one of the views maybe something like this:
<TouchableOpacity onPress={() => this.handleIndexChange(2)}> // this will switch to tab2 if you're on tab1
<Text>Press to switch to tab 2</Text>
</TouchableOpacity>
Please refer to the example code here!
Most helpful comment
First - please make sure you fill out the _issue template_ before you post an issue here. The maintainer is not likely going to entertain your question without it.
Secondly, if I am understanding your question correctly - you mean to ask how do you want to navigate from one screen to the other? If not, the solution below might not be relevant to you.
The navigation object whose
indexproperty matches withindexattribute in the _navigation state_ is rendered.So for example, if your navigation state looks something like this:
Then in both the views which will have the button to navigate/switch tabs you can just update the
indexprop in thestateobject:and your button in one of the views maybe something like this:
Please refer to the example code here!