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:
export default function myReducer (state = initialState, action) {
switch (action.type) {
case THE_ONE_ACTION_I_LISTEN_TO:
return { ...state, ...someNewStuff };
}
}
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
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.
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
undefinedstate 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.