You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Just spent some half an hour figuring this out.
Say I only had one action type to process in my reducer, so, based on my experience with 'vanilla flux', I did it like this:
And (of course it's obvious to me now) I get an undefined state before the first action run, not the initialState. So I had to add the
default: returnstate;
to correctly process the '@@init' action type. AFAIK that's nowhere to be found in the docs currently, guess it's just implied, but maybe mentioning it somewhere could save someone else a bit of time.
The text was updated successfully, but these errors were encountered:
burmisov
changed the title
Reducers (ex-'stores') must have a 'default' return value for state to be initialized properly?
Reducers (ex-'stores') must have a default return value for state to be initialized properly?
Jun 23, 2015
I'd accept a PR checking that the return value of every store function inside composeStores is not undefined. This should cover the most common use case. Folks not using composeStores are assumed to know what they're doing anyway.
This will also need a test in composeStores.spec.js.
Just spent some half an hour figuring this out.
Say I only had one action type to process in my reducer, so, based on my experience with 'vanilla flux', I did it like this:
And (of course it's obvious to me now) I get an
undefined
state before the first action run, not theinitialState
. So I had to add theto correctly process the '@@init' action type. AFAIK that's nowhere to be found in the docs currently, guess it's just implied, but maybe mentioning it somewhere could save someone else a bit of time.
The text was updated successfully, but these errors were encountered: