diegoddox / react-redux-toastr

react-redux-toastr is a toastr message implemented with Redux
http://diegoddox.github.io/react-redux-toastr/
MIT License
752 stars 149 forks source link

Toasts reappear when reducers are replaced #109

Closed kristian-elder closed 7 years ago

kristian-elder commented 7 years ago

I've successfully wired up react-redux-toastr, and notifications appear as expected. However, when we go to a new route in our app, the old notifications appear again.

In the redux dev tools, I can see @ReducToastr/toastr/REMOVE being emitted again after the toast flashes, but no actions for triggering a toast (by our application or toastr itself).

Not sure if it is a route change that triggers it or something else, but for whatever reason, they re-appear.

kristian-elder commented 7 years ago

A bit more context:

We dynamically add reducers to redux when loading routes, ultimately resulting in a call to store.replaceReducer(makeRootReducer(...))

When this happens, toastr appears to replay something and displays the previous toasts again.

Is there a workaround for this?

kristian-elder commented 7 years ago

FYI - we've worked around this in our app by explicitly clearing toasts after injecting new reducers, but would be even nicer if we didn't have it.

kristian-elder commented 7 years ago

Additional additional info: We are using immutable.js for the redux store.

jayden-17 commented 7 years ago

If you used 'react-redux-starter-kit', check this source (https://github.com/davezuko/react-redux-starter-kit/commit/820ca897db802979be2ce46e4d016076744145a2) and this issue(https://github.com/gaearon/redux-devtools/issues/304)

luismendozamx commented 7 years ago

+1 on this issue. We are doing code splitting and loading reducers dynamically. Any pointers or examples on how you solved it @kristian-elder?

Also using immutable.js. Our app is based on https://github.com/react-boilerplate/react-boilerplate

pimvanderheijden commented 7 years ago

I don't have this issue with v4.4.6 Do have it in v5.0.0

Using react-redux-starter-kit

TheSharpieOne commented 7 years ago

https://github.com/gaearon/redux-devtools/issues/304#issuecomment-251715413 worked for me.

diegoddox commented 7 years ago

@kristian-elder are you still having this issue?

kristian-elder commented 7 years ago

Same as TheSharpieOne, applying https://github.com/gaearon/redux-devtools/issues/304#issuecomment-251715413, together with another change that re-injected reducers unnecessarily, has fixed it for us - we are no longer having the problem.

diegoddox commented 7 years ago

Thanks!