react-navigation 返回路由监听

2019-10-30  本文已影响0人  扯扯疯
     componentDidMount() {
        this.didFocus = this.props.navigation.addListener(
            'didFocus',
            () => this._onRefresh()//放你需要执行的函数
        );
    }
    
    componentWillUnmount(){
        this.didFocus.remove();//不要忘了移除监听哦
    }

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

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

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

上一篇 下一篇

猜你喜欢

热点阅读