我尝试从React& Redux第204页的书中实现示例,但是,有一个奇怪的问题 – 在React代码中有TypeError(0,_ColorReducer.color)不是函数错误
我有2个减速器用于一种颜色和颜色数组:
import React from "react";
import * as C from "./Constants";
import { color } from "./ColorReducer";
export const colorsReducer = (state = [],action) => {
switch (action.type) {
case C.ADD_COLOR:
return [...state,color({},action)];
case C.RATE_COLOR:
return state.map(item => color(item,action));
default:
return state;
}
};
和
import React from "react";
import * as c from "./Constants";
export const сolor = (state = {},action = {}) => {
switch (action.type) {
case c.ADD_COLOR:
return {
id: action.id,title: action.title,color: action.color,rating: action.rating
};
case c.RATE_COLOR:
return state.id !== action.id
? state
: {
...state,rating: action.rating
};
default:
return state;
}
};
所以,colorsReducer中的问题在哪里
return state.map(item => color(item,action));
你能帮我理解一下原因吗?
最佳答案
c字颜色是用其他语言..