react-navigation 返回路由监听

     componentDidMount() {
        this.didFocus = this.props.navigation.addListener(
            'didFocus',
            () => this._onRefresh()//放你需要执行的函数
        );
    }
    
    componentWillUnmount(){
        this.didFocus.remove();//不要忘了移除监听哦
    }

在进入或者返回这个页面的时候 会执行_onRefresh方法

_onRefresh可以放获取页面数据的方法,当进入页面获取数据,从其他页面返回到这个页面再次请求数据。

ps:指定页面返回使用指定返回callback

你可能感兴趣的:(react-navigation 返回路由监听)