我收到了错误消息
“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);
}
CategoryContainer.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
};
}
CategoryReducer.js:
const initialState = {
categories:[],
}
export default function categoryReducer (state = initialState, action) {
switch (action.type) {
case CATEGORY_VIEW:
return Object.assign({}, state, {
categories: action.categories
});
}
}
CategoryContainer.js中的以下行引发错误消息, stores.dispatch(CategoryAction.categoryView());
请协助解决问题。
答案 0 :(得分:2)
在CategoryContainer.js中,您需要导入CategoryActions.js的特定成员(或所有成员)。应该是以下两个选项之一:
android:inputType=""