【发布时间】:2020-04-15 13:22:24
【问题描述】:
我有一个名为 PAGE2 的组件,我将从该组件返回到组件 PAGE1。现在,当我使用不同的道具从 PAGE1 移动到 PAGE2 时,我看到 PAGE2 具有旧值(此处未调用包含 fetchListValues 函数的 componentDidMount)
我从第 2 页到第 1 页使用 导航.navigate('PAGE1');
componentDidMount = () => {
// in page 2
this.fetchChats();
this.backHandler = BackHandler.addEventListener(
"hardwareBackPress",
this.handleBackPress
);
};
handleBackPress() {
console.log('Back pressing', this.props.navigation);
this.props.navigation.navigate('PAGE1');
return true;
}
componentWillUnmount() {
console.log('Hitting component will unmount');
BackHandler.removeEventListener("hardwareBackPress",
this.handleBackPress);
}
【问题讨论】:
-
请提供您的代码minimal reproducible example - 如果他们看不到您所写的内容,任何人都无法提供帮助。
标签: reactjs react-native