Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

新手求助~请问怎么在页面getInitialProps获取更新后的reduxStore喃?谢谢~ #1

Open
LW728 opened this issue Sep 19, 2019 · 1 comment

Comments

@LW728
Copy link

LW728 commented Sep 19, 2019

我在_app中修改了state的值,用redux浏览器工具查看,值是修改了的,但是在页面getInitialProps中获取到的reduxStore是初始化的值:
static async getInitialProps({req,query,query:{id,param},reduxStore}){
console.log(reduxStore.getState())
}

@shaotianyu
Copy link
Owner

我在_app中修改了state的值,用redux浏览器工具查看,值是修改了的,但是在页面getInitialProps中获取到的reduxStore是初始化的值:
static async getInitialProps({req,query,query:{id,param},reduxStore}){
console.log(reduxStore.getState())
}

当页面初次加载时,getInitialProps只会在服务端执行一次;
getInitialProps只有在路由切换的时候(如Link组件跳转),客户端的才会被执行。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants