Learning Redux.js and building a demo app.
I have a reducer set like this:
// Imports here
function blocksFunc(state = [], action) {
switch (action.type) {
case 'ADD_BLOCK':
_id++;
return [...state, {'_class' : 'basic', '_id' : _id }];
default:
state = [];
return state;
}
}
const BlockGeneratorReducer = combineReducers({
blocksFunc,
});
export default BlockGeneratorReducer;
I successfully update the state, but when logging I get the following when page loads:
blocksFunc() type: "@@redux/INIT"
blocksFunc() type: "@@redux/PROBE_UNKNOWN_ACTION_b.f.4.qyoav2.t.9"
blocksFunc() type: "@@redux/INIT"
So blocksFunc function is launched three times with default action.type. On which occasions is the action type "@@redux/INIT" launched? What might "@@redux/PROBE_UNKNOWN_ACTIOM" refer in to?
The full source can be found on git: https://github.com/JaakkoKarhu/redux-react-blockgenerator
The working demo is uploaded to my server: http://jaakkokarhu.com/playground/redux-block-generator/
Since being new with React and Redux, all the other comments regarding the source are also very welcome.
EDIT:
blocksFunc() edited according to DavidWalshes advice.
@@redux/INIT is launched twice on purpose. First time is for testing combineReducers, second one is actual init: https://github.com/reactjs/redux/issues/382
As TenorB pointed out on question comments, @@redux/PROBE_UNKNOWN_ACTION is also launched for testing purpose.
So, after all, these events are not accidentally launched.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.