I want to make remove item reducer add item reducer is :
export const addItems= (state= [], action)=> {
switch (action.type) {
case 'ADD_ITEM':
return [
...state,
action.product
]
default:
return state;
};
};
action creator for add itme is :
export const showItems = (author,price) =>{
return((dispatch)=>{
dispatch({
type:'ADD_ITEM',
product:{
author,
price
}
});
});
};
remove action creator is :
export const removeItem = (index) =>{
return((dispatch)=>{
dispatch({
type:'REMOVE_ITEM',
payload: index
});
});
};
the map function that show list item :
{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>
);
})}
my question is : what is remove item reducer?