我想让删除项目减速器添加项目减速器是:
export const addItems= (state= [], action)=> {
switch (action.type) {
case 'ADD_ITEM':
return [
...state,
action.product
]
default:
return state;
};
};
add itme 的动作创建者是:
export const showItems = (author,price) =>{
return((dispatch)=>{
dispatch({
type:'ADD_ITEM',
product:{
author,
price
}
});
});
};
删除动作创建者是:
export const removeItem = (index) =>{
return((dispatch)=>{
dispatch({
type:'REMOVE_ITEM',
payload: index
});
});
};
显示列表项的地图功能:
{showItems.map((item, index)=>{
return(
<ul key={index} className='d-flex justify-content-around'>
<button
type='button'
className='btn-close btn-danger'
/>
<p>{item.author}</p>
<p>{item.price}</p>
</ul>
);
})}
我的问题是:什么是remove item reducer?