I've adapted a with-redux-thunk example from next.js. In this example, we are removing the redux state on the client, every time we hit the SSR page.
I have 3 pages, - 2 of them are Server-side rendered, and 1 is Client-side rendered.
My "Goal" is to reset the "redux state" whenever I go from Server-side pages to the Client-side page.
To accomplish the goal, - in every SSR page, I've added "react hook cleanup functions" in which I dispatch reset actions
useEffect(() => {
return () => {
console.log("leave ssr page 1");
dispatch({ type: "RESET" });
};
}, [dispatch]);
But I noticed an "issue" - when I switch from the SSR page 1 to SSR page 2, the cleanup function dispatches a reset action to the "Stale" state without any effects. It can be seen in the browser console via redux-logger.
Question: Is it a critical "issue", or I can just ignore it?
CodeSandbox: issue sandbox
