Created
November 21, 2021 22:34
-
-
Save BrianJenney/bd838165e0e990c00f9ad539aa28fe15 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Cart = ({items}) => { | |
const dispatch = useDispatch() | |
const isLoggedIn = useSelector((state) => state.account.isLoggedIn) | |
const clearCart = () => { | |
dispatch(reduxActionToClearCart()) | |
} | |
if(!isLoggedIn){ | |
return <LoginPrompt/> | |
} | |
return( | |
<div> | |
<div> | |
{items.map(({price, name}) => { | |
return( | |
<ItemDisplay price={price} name={name}/> | |
) | |
}) | |
<button onClick={() => clearCart()}>Clear Cart</button> | |
</div> | |
</div> | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment