繁体   English   中英

在UC浏览器中首次渲染时调用componentWillReceiveProps

[英]componentWillReceiveProps being called on first render in 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 仅在已安装的组件接收到新的prop时才被调用 这适用于所有移动浏览器, 但UC浏览除外
在UC浏览器上,首次加载服务器呈现页面时,在安装组件之后,调用componentWillReceiveProps并发现(prevUrlParam === nextUrlParam)为假,从而导致数据被提取。
对于不同的浏览器,React生命周期功能是否以不同的方式工作,还是相对于UC浏览器而言是一个错误?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM