-
Hey guys, first of all thanks for the great work, I really like zustand and I'm probably just doing something wrong but I have to ask how to properly reset the store state into the initial state before we leave the page. I'm doing that currently in useEffect unmounting but it seems like the store is set to initial state after the next page is actually initialized. I've prepared a simple demo. The issue can be spotted in the console when you navigate from landing.jsx to page.jsx, so I'm getting some data at landing page and setting the isSuccess and message values in the store and resetting them in useEffect unmount. After navigating to page.jsx, you can see in console.log that the resetting will run after the page.jsx is rendered. So my question is, am I doing something wrong or it is normal scenario. Thank you very much. store.js
landing.jsx
page.jsx
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
I think it's how react-router behaves. Can anyone confirm? |
Beta Was this translation helpful? Give feedback.
-
Hmmm, I'm not sure what's best with the React-Router v6 API. |
Beta Was this translation helpful? Give feedback.
I think it's how react-router behaves. Can anyone confirm?