react服务端渲染同构如何监听url参数改变从而改变页面显示?

以前在react SPA 项目中,我会通过react生命周期监听参数的变化,然后重新请求数据,但是服务端渲染没有此生命周期,如何监听?
原来的代码:

componentWillReceiveProps(nextProps) {
        const { location } = this.props;
        if (nextProps.location.pathname !== location.pathname) {
            this.setMetas();
        }
    }
阅读 2.2k
1 个回答

这个componentWillReceiveProps生命周期都要废弃了。
reduxsubscription监听就好了。

推荐问题