Reactjs Redux action.type给出了@Redux/INIT
我的reducer文件如下Reactjs Redux action.type给出了@Redux/INIT,reactjs,redux,Reactjs,Redux,我的reducer文件如下 import { AppConstants } from '../constants'; const initialState = { state: [], menu_items: [], addon_items: [], save_items: [], un_mapped_menu_items: false, error: '' }; export default (state = initialState, action) =>
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
}
};
调试reducer文件时,action.type显示'@@redux/INIT'。我不明白这一点。为什么会这样呢?我的操作文件在调试时提供了正确的数据。如何删除此错误?创建存储时,
@@redux/INIT
操作由createStore
从代码中:
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 })
请参见此处的代码:
如何调试?您在什么时候记录操作类型?顺便说一句,reducer不生成动作,这就是为什么要显示动作创建者文件的原因。共享实际获取动作的代码,如果通过AJAX,则共享AJAX调用代码。