My reducer file is as follows.
import { AppConstants } from '../constants';
const initialState = {
state: [],
menu_items: [],
addon_items: [],
save_items: [],
un_mapped_menu_items: false,
error: ''
};
export default (state = initialState, action) => {
switch (action.type) {
case AppConstants.getMenuItems:
return {
...state,
}
case AppConstants.getMenuItemsSuccess:
return {
...state,
menu_items: action.menu_items
}
case AppConstants.getAddonsItems:
return {
...state,
}
case AppConstants.getAddonsItemsSuccess:
return {
...state,
addon_items: action.addon_items
}
case AppConstants.getMenuItemsEdit:
return {
...state,
}
case AppConstants.getMenuItemsSave:
return {
...state,
save_items: action.save_items
}
case AppConstants.getUnmappedMenuItems:
return {
...state,
error: action.error,
un_mapped_menu_items: true
}
case AppConstants.getMenuItemsError:
return {
...state,
error: action.error
}
default:
return state
}
};
When I debug my reducer file the action.type shows '@@redux/INIT'. I do not understand this . why does this gives this? My action file gives correct data when debugging it. How do I remove this error?
When a store is created an @@redux/INIT
action is dispatched by createStore
From the Code:
export var ActionTypes = {
INIT: '@@redux/INIT'
}
// When a store is created, an "INIT" action is dispatched so that every
// reducer returns their initial state. This effectively populates
// the initial state tree.
dispatch({ type: ActionTypes.INIT })
See the code here: https://github.com/reactjs/redux/blob/v3.0.6/src/createStore.js
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With