反应本机重新安装屏幕
问题描述:
在我的第一页上我有一个列表,我得到一个列表。这在第一次通话中有效。但是,当我去到其他屏幕this.props.navigation.navigate('OtherScreen');
,并返回到旧屏幕反应本机重新安装屏幕
const backAction = NavigationActions.back({
key: null,
});
this.props.navigation.dispatch(backAction)
我的名单不会得到刷新,因为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', {})