redux-devtools icon indicating copy to clipboard operation
redux-devtools copied to clipboard

When there is no state, show previous state?

Open gaearon opened this issue 11 years ago • 2 comments

If the reducer throws for every action, getState() visible to the app will return undefined with DevTools enabled (which will display the error). This usually blows up the app badly because all kinds of store.subscribe() calls expect state to at least be there.

I propose to cache the last non-undefined state, and in the event that the current state is undefined because reducer error'd, return the last non-undefined state. Thoughts?

gaearon avatar Sep 13 '15 04:09 gaearon

This seems reasonable to me, and better than the current behaviour. I'm going to write some tests for #9, and after that I'm going to try implementing this.

ellbee avatar Sep 18 '15 22:09 ellbee

Done in 2.1.4.

gaearon avatar Sep 25 '15 22:09 gaearon