Answer the question
In order to leave comments, you need to log in
The component is not updated after props, why?
Hello, there is a code that accepts some goods in a prop.
When you click on the 'add item' button, it adds it to the cart in redux.
When adding, everything works fine, but there is a problem with deleting from the trash.
Deleted elements will disappear from the interface only when a new product is added
Everything seems to be fine with the redux itself, it removes and adds elements correctly, returns not a mutated, but a new object: return {...cartInfo};
This is how the basket elements are created:
useEffect(()=>{
setList(props.cart.map((item, index) =>{
return <OpenCartElement info={item} />
}))
},[props])
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question