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

When there is no state, show previous state? #106

Closed
gaearon opened this issue Sep 13, 2015 · 2 comments
Closed

When there is no state, show previous state? #106

gaearon opened this issue Sep 13, 2015 · 2 comments

Comments

@gaearon
Copy link
Contributor

gaearon commented Sep 13, 2015

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?

@ellbee
Copy link
Collaborator

ellbee commented Sep 18, 2015

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.

gaearon added a commit that referenced this issue Sep 24, 2015
Return last non-undefined state from getState() #106
@gaearon
Copy link
Contributor Author

gaearon commented Sep 25, 2015

Done in 2.1.4.

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