在redux中发送操作

在redux中发送操作,redux,Redux,我创建了一个应用程序,可以模拟购买产品。因此,当我点击BUY按钮时,水果的数量应该会减少。 我想问题出在我的减速机上,但我不知道在哪里 ///// 常量水果=(道具)=>{ 控制台日志(道具); 返回( 水果数:{props.numFruits} 购买 ); }; 常量mapStateToProps=(状态)=>{ 返回{ numFruits:state.numFruits } }; const mapDispatchToProps=(调度)=>{ 返回{ BuyFrootsAction:()

我创建了一个应用程序,可以模拟购买产品。因此,当我点击
BUY
按钮时,水果的数量应该会减少。 我想问题出在我的减速机上,但我不知道在哪里

/////
常量水果=(道具)=>{
控制台日志(道具);
返回(
水果数:{props.numFruits}
购买
);
};
常量mapStateToProps=(状态)=>{
返回{
numFruits:state.numFruits
}
};
const mapDispatchToProps=(调度)=>{
返回{
BuyFrootsAction:()=>调度(BuyFrootsAction())
}
};
导出默认连接(mapStateToProps、mapDispatchToProps)
////减速器
从“./类型”导入{购买水果};
常量初始状态={
numFruits:10
};
const reducer=(state=initialState,action)=>{
开关(动作类型){
案例购买水果:退货{
……国家,
numFruits:state.numFruits-1
};
默认:返回状态;
}
};

导出默认减速机这一行就是问题所在:

<button onClick={buyFruitsAction}>BUY</button>
购买

没有变量
BuyFrootsAction
,它是一个属性。所以这应该是
道具。购买水果动作

你的减速机很好,你能发布你的动作创建者吗

组件中未定义buyFruitsAction。您是指道具。buyFruitsAction