gpt4 book ai didi

react-native - React Native 重新安装屏幕

转载 作者:行者123 更新时间:2023-12-02 03:49:00 25 4
gpt4 key购买 nike

在我的第一页上,我有一个列表,我通过获取获得该列表。这在第一次调用时有效。但是当我使用 this.props.navigation.navigate('OtherScreen'); 转到另一个屏幕并使用

返回旧屏幕时
 const backAction = NavigationActions.back({
key: null,
});
this.props.navigation.dispatch(backAction)

我的列表不会刷新,因为我调用 fetch 的 componentDidMount 方法不会再次触发。我也尝试过 componentWillUpdate,但这也不会再次触发。

当我进入屏幕时,如何强制屏幕重新安装?

最佳答案

你可以试试这个https://facebook.github.io/react/docs/react-component.html#forceupdate .

或者,如果我正确理解了任务

//screen A
import {DeviceEventEmitter} from 'react-native'
componentWillMount() {
DeviceEventEmitter.addListener('your listener', (e)=>{})
}

//screenB
DeviveEventEmitter.emit('your listener', {})

关于react-native - React Native 重新安装屏幕,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46002972/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com