The client-side state is not hydrated from the server after creating a new store
CodeSandBox Link - https://codesandbox.io/s/vibrant-aryabhata-l29r2b
Steps to reproduce the behavior:
On page reload, upon hydration client should also get authenticated, and hence console would print logged in true.
You can clearly see in the screenshot above that as per hydration (__NEXT_REDUX_WRAPPER_HYDRATE__
), the state is updated correctly but on console log on the client-side, I am getting loggedin
as false.
I am stuck at it for a while and really don't know if there is anything wrong with my code or is a bug. Please look into it and suggest accordingly.
You have a minor misconfiguration. next-redux-wrapper
already adds a Provider with the correct store. You need to remove the extra provider you're putting in _app.js
. That was the reason why the component wasn't getting the correct data.
render() {
const { Component, pageProps, router } = this.props;
return <Component {...pageProps} router={router} />;
}