-
Notifications
You must be signed in to change notification settings - Fork 644
Dev Tools reset wipes out location state #207
Comments
Getting this issue as well. Using Redux DevTools, if you load a page, click "Reset" or "Commit", go between between pages, then try to replay the route changes, you get: Uncaught TypeError: Cannot read property 'action' of undefined If you don't Reset the state, then no issue occurs during replay. I wasn't getting this issue in 1.x. |
i'll attempt. just found out that // looks like we'll need to parse the queries as well. edit: really no idea how we can do this without a hack or something. https://gist.github.com/srph/d574716c86b68604222f#file-index-js-L80 |
Can anyone point out if the |
This is inherit in how this works -- we need to read the location first from |
I couldn't get it to work by setting the initial state to a blank object. Following @timdorr's suggestion, I've set the initial state to the window's location, string, and hash as follows: const initialState = typeof window === undefined ? {} : {
location: {
pathname: window.location.pathname,
search: window.location.search,
hash: window.location.hash
}
} This has worked so far in my few tests. It seems to mimic the fix for this issue when it occurred earlier on. Rather than setting the path to the concatenation of the window.location pathname, search, and hash, it sets the location object appropriately. |
@vga- we used to do something like that, but it doesn't work reliably. We want the initial location from the router, because the actual URL location is abstracted away. If you are using HashHistory your code breaks. |
I don't see what could be wrong with setting the initial location to a blank object. You will have to replay the first action to actually set the URL, yes, but that is exactly what is happening when the app loads. |
It's loosely related to #193. When the middleware is created, it gets the location via I think it should be safe to set the |
Nevermind. I didn't know the basic example already had them 😄 |
Thanks <3 |
I'm not sure if this is a bug or an issue with my code. Let me know if I'm submitting this to the wrong place.
Whether this was intended or not, please let me know.
Behavior
The state.routing.location key loses its value when the state is reset.
Demo
https://github.com/chirigarikku/redux-simple-router-2-reset-state-bug
The text was updated successfully, but these errors were encountered: