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

Replacing reducer on store makes Devtools replays all actions from beginning #291

Closed
yachaka opened this issue Jun 12, 2016 · 3 comments
Closed

Comments

@yachaka
Copy link

yachaka commented Jun 12, 2016

I've been noticing that replacing the reducer on the store dispatch an @@INIT action.
When combined with redux-devtools or redux-devtools-extension, it seems to be replaying all actions since beginning each time you replace the reducer.

Fast recipe to reproduce :

  1. git clone https://github.com/mxstbr/react-boilerplate.git && cd react-boilerplate && npm install
  2. Install redux-devtools-extension
  3. Add console.log('Reducer called', action) at the start of appReducer in ~/app/containers/App/reducer.js
  4. Open console, go to http://localhost:3000, move back and forth between the Features and the Home page, and watch the log output

Mind that the replay will only occur when going to the Home page and not when going to the Features page. This is due to the fact that the Features page is not injecting a reducer, and so not replacing the store's reducer, while the Home page is.

@yachaka
Copy link
Author

yachaka commented Jun 12, 2016

I'm digging a little bit into the redux-devtools-instrument code right now.
It seems like the actions only gets re-reduced. It isn't a concern then, though it is a little bit weird as they only get re-reduced in the tool.

@zalmoxisus
Copy link
Collaborator

@yachaka, the purpose of the recomputing is to get new values after you change something in the reducers. See more details in Dan's talk.

Also, reducers are called when you toggle (cancel) an action down the history tree.

@zalmoxisus
Copy link
Collaborator

Related to #304.

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

No branches or pull requests

2 participants