React Native-REDUX误差:未定义不是对象(评估



我有错误消息

" undefined不是对象(评估categoryAction2.default.CategoryView')在执行以下代码上,

configurestore.js:

import {createStore, applyMiddleware} from 'redux';
import reducers from '../reducers';
import thunk from 'redux-thunk';
var middlewares = applyMiddleware(thunk);
export default function configureStore(initialState) {
  return createStore(reducers, initialState, middlewares);
}

类别container.js:

import React, { Component } from 'react';
import stores from '../stores/ConfigureStore';
import CategoryAction from '../actions/CategoryAction';
stores.dispatch(CategoryAction.categoryView());
class CategoryContainer extends Component {
}

categoryAction.js

import * as actionTypes from './ActionTypes';
import AppConstants from '../constants/AppConstants';
export function categoryView() {
  const categories = ['Health', 'Built-in'];
  return {
      type: "CATEGORY_VIEW",
      categories: categories
  };
}

类别Reducer.js:

const initialState = {
  categories:[],
}
export default function categoryReducer (state = initialState, action) {
  switch (action.type) {
    case CATEGORY_VIEW:
      return Object.assign({}, state, {
              categories: action.categories
            });
    }
}

类别中的下行。stores.dispatch(categoryAction.categoryview());

请帮助解决问题。

在categoryContainer.js中,您需要导入类别的特定成员(或所有成员)。应该是以下两个选项之一:

import * as CategoryAction from '../actions/CategoryAction';
// or
import { categoryView } from '../actions/CategoryAction';
stores.dispatch(categoryView());

相关内容

  • 没有找到相关文章

最新更新