在UC浏览器

时间:2017-06-06 12:56:17

标签: reactjs react-router uc-browser

我使用React,React路由器和Redux实现单页面应用程序。它使用通用渲染。
React组件ArticleListComponent显示新闻文章列表。 单击移动浏览器的后退按钮时,React生命周期功能 componentWillReceiveProps 会比较当前道具和nextProps的路径(如下面的代码段所示),并相应地获取数据。

componentWillReceiveProps (nextProps) {
    var prevUrlParam = this.props.match.params;
    var nextUrlParam = nextProps.match.params;
    if(prevUrlParam === nextUrlParam) { 
        return;
    }
    // else data fetch for previous page
}

根据文档(https://facebook.github.io/react/docs/react-component.html#componentwillreceiveprops),仅当已安装的组件收到新的道具时才会调用 componentWillReceiveProps 。这适用于所有移动浏览器,除了UC浏览器
在UC浏览器上,在首次加载服务器呈现页面时,在安装组件后,将调用componentWillReceiveProps并且发现(prevUrlParam === nextUrlParam)为false,从而导致获取数据。
对于不同的浏览器,React生命周期功能是否有不同的工作方式,或者这是UC浏览器的错误?

0 个答案:

没有答案