reduxjs / redux-devtools

DevTools for Redux with hot reloading, action replay, and customizable UI

Home Page:http://youtube.com/watch?v=xsSnOQynTHs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

replaceReducer with shouldHotReload: false erases action history

bdwain opened this issue · comments

I am trying to implement code splitting in my app, and I call replaceReducer when a new reducer is loaded. I use the shouldHotReload: false option to avoid rerunning actions, but now the actions dispatched before replaceReducer are erased from the action history when viewing the devtools. I just see @@init and then ASYNC_LOAD_COMPLETE, which is dispatched after replaceReducer runs successfully.

Is it possible to preserve the state transitions and actions from before replaceReducer?

Note: I am using the redux devtools chrome extension, so it may just be an issue in that project. But since it uses this library, I just assumed this behavior came from here and not there. If that's wrong I can refile with them.

Running into the same issue - all state transitions prior to replaceReducer() being called disappear (although the actions themselves still appear in the Inspector and Log monitor views).

See more details in this issue: #559.

commented

@Methuselah96 would you accept a PR to fix this? This is causing issues with the redux-injectors library that I help maintain

My half-informed suspicion is that there might not be a feasible resolution, because the DevTools relies on replaying actions to show the state at that point in time. If a reducer gets swapped out now, running the "old" actions through it would presumably result in states that don't match what the state was when the original dispatches happened. Happy to be proven wrong here, but that's my first thought.

One option to improve it would be to store old reducers as well as the current one, so that when replaying actions, it uses the reducer that was current at that time.

Another would be to show the action history but disable replayability before the last call to replaceReducers.

I think both of those would be an improvement over the current behavior. Thoughts?

Hmm. That could hypothetically work, although there'd have to be bookkeeping to know which actions were dispatched when a given reducer was in use.

I know this thread is somewhat dead, but I wonder if there's a way to differentiate between the replaceReducer used by the hot reload and user usage of the replaceReducer function. It's actually really annoying having to set shouldHotReload to false, simply because I'm trying to code split my reducers and use the devtools.

Still running into this issue, which is really annoying, is there any progress with it ?