【发布时间】:2018-03-21 10:31:09
【问题描述】:
我在 react native 中遇到了一个问题,但还没有得到任何解决方案。 我使用 TabNavigator。当我单击一个选项卡时,它将成功调用其中的组件。但是当我通过离开组件离开另一个选项卡,然后返回上一个选项卡时,数据仍然存在/存在。它根本不会重新渲染。 如何在 TabNavigator 中重新加载组件?我尝试使用 redux 并在组件类中实现 componentDidUpdate 但它根本没有被调用,似乎这不是问题。它只是没有被第二次调用的组件类 请帮忙。
我的 TabNavigator 代码:
const AppTabNav = TabNavigator({
Home: {
screen: AppStack,
navigationOptions: {
fontSize: 4,
}
},
Notification: {
screen: RequestStack,
navigationOptions: {
// headerTitle: 'HRIS',
// label: 'HRIS',
fontSize: 4
}
},
Request222: {
screen: NotifStack,
navigationOptions: {
headerTitle: 'HRIS',
label: 'HRIS',
fontSize: 4
}
},},
{
tabBarPosition: 'bottom',
animationEnabled: true,
swipeEnabled: true,
tabBarOptions: {
activeTintColor: '#022846',
// inactiveBackgroundColor: '#89898b',
inactiveTintColor: '#89898b',
upperCaseLabel: false,
// activeBackgroundColor:'#fff',
showLabel: true,
showIcon: true,
// style: styles.tabBar,
style: {
backgroundColor: '#eaeaec'
},
},
});
【问题讨论】:
标签: android reactjs react-native react-navigation