【发布时间】:2020-07-16 18:11:48
【问题描述】:
错误:
./src/reducers/productReducers.js
Line 3:10: 'PRODUCT_LIST_REQUEST' is not defined no-undef
Line 5:10: 'PRODUCT_LIST_SUCCESS' is not defined no-undef
Line 7:10: 'PRODUCT_LIST_FAIL' is not defined no-undef
下面是我的代码
function productListReducer(state = { products: [] }, action) {
switch (action.type) {
case PRODUCT_LIST_REQUEST:
return { loading: true, products: [] };
case PRODUCT_LIST_SUCCESS:
return { loading: false, products: action.payload };
case PRODUCT_LIST_FAIL:
return { loading: false, error: action.payload };
default:
return state;
}
}
export { productListReducer };
【问题讨论】:
-
你能在你定义这些动作类型的地方添加代码吗?我认为您忘记从各自的文件中导入这些操作类型。