Skip to content

document assertReducerSanity behavior #1633

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

Merged
merged 1 commit into from
Jul 19, 2016
Merged

document assertReducerSanity behavior #1633

merged 1 commit into from
Jul 19, 2016

Conversation

ruggeri
Copy link
Contributor

@ruggeri ruggeri commented Apr 19, 2016

It is not clear from the documentation that it is insufficient to merely avoid ever passing in undefined as state by using initial state. assertReducerSanity will test that your reducer does the right thing when passed undefined, even if you never intend for it to be called this way.

This documentation change makes that behavior clearer, in the hopes of saving new users from needless frustration. It was very confusing to see my reducer passed undefined even though I never intended it to be used that way. I did not suspect combineReducers would do this.

Hope this helps!

It is not clear from the documentation that it is insufficient to
merely avoid ever passing in `undefined` as state by using initial
state. `assertReducerSanity` will test that your reducer does the
right thing when passed `undefined`, even if you never intend for it
to be called this way.

This documentation change makes that behavior clearer, in the hopes of
saving new users from needless frustration.
@gaearon
Copy link
Contributor

gaearon commented Apr 19, 2016

Yeah. Ideally we should also explain why this is the case.
Some context here: #1617 (comment)

I like your changes but please consider the broader picture—I’d be happy if you could take tweak createStore.md to better clarify initialState role while you’re at it. Let me know if it’s too much to ask though 😄

Thanks!

@timdorr
Copy link
Member

timdorr commented Jul 19, 2016

We can add that in another PR, I suppose. Let's get this in for now. Thanks, @ruggeri!

@timdorr timdorr merged commit f24aa20 into reduxjs:master Jul 19, 2016
seantcoyote pushed a commit to seantcoyote/redux that referenced this pull request Jan 14, 2018
It is not clear from the documentation that it is insufficient to
merely avoid ever passing in `undefined` as state by using initial
state. `assertReducerSanity` will test that your reducer does the
right thing when passed `undefined`, even if you never intend for it
to be called this way.

This documentation change makes that behavior clearer, in the hopes of
saving new users from needless frustration.
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

Successfully merging this pull request may close these issues.

3 participants