this is the react code and i want to access the cart value and totaPrice value inside the return
function A() {
const Cart = () => {
const [cart, setCart] = useContext(CartContext);
const totalPrice = cart.reduce((acc, curr) => acc + curr.add, 0);
};
return <div>i want to use {totalPrice} value here how can I?</div>;
}
export default A;