Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replaceReducer with shouldHotReload: false erases action history #378

Open
bdwain opened this issue Aug 8, 2017 · 8 comments
Open

replaceReducer with shouldHotReload: false erases action history #378

bdwain opened this issue Aug 8, 2017 · 8 comments

Comments

@bdwain
Copy link

bdwain commented Aug 8, 2017

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.

@jmar777
Copy link

jmar777 commented Sep 18, 2017

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).

@Methuselah96
Copy link
Member

See more details in this issue: #559.

@BenLorantfy
Copy link

BenLorantfy commented Apr 24, 2021

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

@markerikson
Copy link

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.

@bdwain
Copy link
Author

bdwain commented Apr 25, 2021

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?

@markerikson
Copy link

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.

@DanielCashlink
Copy link

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.

@piechoo
Copy link

piechoo commented Aug 19, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants