Tell us which versions you are using:
lazy
showIcon
key="tabs"
showLabel={false}
tabBarPosition="bottom"
>
there four tabs ,I switch tab to tab, is there anyway to know that I will switch tab1 to tab2,and I can decide go or not to go next scence?
when I switch between tabs, I can get nothing from componentwillUpdate
My experience use "lazy" props
<Tabs
key='home'
tabs
tabBarPosition='bottom'
animationEnabled={false}
gestureEnabled={false}
showLabel={false}
swipeEnabled={false}
hideNavBar
tabBarStyle={styles.tabBarStyle}
navigationBarStyle={styles.navBarStyle}
lazy
>
@duyluonglc the lazy prop did not help,whether there has lazy ,the component only mounted once
lazy
showIcon
key="tabs"
showLabel={false}
tabBarPosition="bottom"
>
Yes the component will mount once time. You can use onEnter prop to know when the tab is focused
My example everytime focus to favorite tab I do reload favorite data
class Favorite extends Component {
static onEnter = () => {
Actions.refresh({
enterTime: new Date()
})
}
componentWillReceiveProps (nextProps) {
this.forceUpdate()
if (this.props.enterTime !== nextProps.enterTime) {
this.getFavorites()
}
}
@duyluonglc static onEnter = () => {
} I wrote onEnter method like you, but onEnter not executed.
@duyluonglc now executed, thank you
When the tabs are "loaded" they are continuously in the navigation "state" so they only mount once and stay mounted. If you are looking for something when you enter or exit a scene, I believe there are some API methods you can attach to your tabs for this purpose.
This is a good solution if you want to reload on pop.
Does the onEnter method work in v3.43.0?
Most helpful comment
Yes the component will mount once time. You can use onEnter prop to know when the tab is focused
My example everytime focus to favorite tab I do reload favorite data