React Native 实现页面返回监听

A页面

import {DeviceEventEmitter} from 'react-native'
 
componentDidMount() {
    // 这里的`param`可以为空,接受你B页面传过来的数据
    this.subscription = DeviceEventEmitter.addListener("EventType", (param)=>{
        // 刷新界面等
    });
}
 
componentWillUnmount() {
    this.subscription.remove();
}

B页面

import {DeviceEventEmitter} from 'react-native'
 
onPress={() => {
    this.props.navigation.navigate('A');
    // 这里的param可以写可以不写自己需要带参数就可以写
    DeviceEventEmitter.emit("EventType", param);
}}>