H
H
Hlib2019-09-12 08:19:48
React
Hlib, 2019-09-12 08:19:48

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])

What could be the problem?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Robur, 2019-09-12
@Robur

First, check if the effect works on removal.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question