Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/72.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs Redux action.type给出了@Redux/INIT_Reactjs_Redux - Fatal编程技术网

Reactjs Redux action.type给出了@Redux/INIT

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) =>

我的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) => {
 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调用代码。