useSelector() Redux

useSelector() Redux

With useSelector() , returning a new object every time will always force a re-render by default.

useSelector sets up a subscription to Redux. So whenever our Redux store does change this component function will be re - executed and we will get to the latest state. So in this case, the latest cart. So that means that effect will also be re - evaluated and it will re - execute if our carts did change and that is exactly what we need