I'm trying to create a redux toolkit that store an object so I could read the object values from different components on different react-router path
when calling to read the values that stores in the redux store, I'm getting the initial state I defined in the redux store instead of the updated value. (in this case I'm getting '0')
I'm pretty sure it is because of this "window.location.replace('/info');" because when I comment it out and called to read the value from the store (in the same component) it works (it doesn't work only after this line)
How should I store those values correctly ? Thank you
If you reload (this operation append with window.location.replace, the store create with Redux-TK is erase and restart. You need to you use React-Router (or React-Router-Dom for web) and use navigate to change your path without reload.
https://reactrouter.com