无法使用'in'运算符在Symbol(react.element)中搜索'toMap'

时间:2018-10-08 11:22:42

标签: reactjs react-redux reducers

一切正常,但只有 对于redux-persist集成,我删除了与我购买的主题一起使用的sega。一切正常,但出现这样的错误 我该怎么解决

  

TypeError:无法使用“ in”运算符在其中搜索“ toMap”   符号(反应元素)错误。

TypeError: Cannot use 'in' operator to search for 'toMap'

(index.js:141) immutable.js in code

模拟菜单应用

import Data from '../data';

class mockMenuApi {
  static getMenu() {
    return new Promise((resolve) => {
      setTimeout(() => {
        let menus = Data.menus;
        let openViews = [];
        let selectedMenuItem = null;
        let selectedOpenedMenuItem = null;

        if (Object.prototype.toString.call(menus) === '[object Array]'
        && menus.length > 0) {
          selectedMenuItem = menus[0];
          openViews = menus.slice(0, 1);
          selectedOpenedMenuItem = openViews[0];
        } else {
          menus = [];
        }

        resolve({
          menus,
          openViews,
          selectedMenuItem,
          selectedOpenedMenuItem,
        });
      }, 500);
    });
  }
}

export default mockMenuApi;

全局操作js

export function loadMenu() {
  return async dispatch => {
    var data = await mockMenuApi.getMenu();
    if (data) {
      dispatch({
        type: ActionTypes.LOAD_MENU_SUCCESS,
        data
      });
    }
  };
}

全局减速器

import { fromJS } from 'immutable';
import * as ActionTypes from './constants';

const initialState = fromJS({
  user: {},
  errors: [],
  signOutErrorMessage: '',
  authenticationErrorMessage: '',
  registrationErrorMessage: '',
  menus: [],
  openViews: [],
  selectedMenuIndex: 0,
  selectedMenuItem: null,
  selectedOpenedMenuIndex: 0,
  selectedOpenedMenuItem: null,
  userIsAuthenticated: false,
  currentTheme: 'darkBlueTheme',
  openSettingDrawer: false,
  showTabs: true,
  showOpenViews: false,
  isBoxedLayout: false,
});


case ActionTypes.LOAD_MENU_SUCCESS: {
  const data = action.data;
  // console.log(data.menus);
  return state.set('menus', data.menus)
    .set('openViews', data.openViews)
    .set('selectedMenuItem', data.selectedMenuItem)
    .set('selectedOpenedMenuItem', data.selectedOpenedMenuItem);
}

0 个答案:

没有答案