function CartScreen() {
const {
cart, // current cart or null
loading, // fetching state
error, // last error
refetch, // reload cart from API
addLines, // add items
updateLines, // change quantities
removeLines, // remove items
clearCart, // start fresh
getCheckoutUrl, // get Shopify checkout URL
updateBuyerIdentity, // set customer on cart
} = useCart();
if (loading && !cart) return <Loading />;
const lines = cart?.lines?.edges ?? [];
return (
<View>
{lines.map(({ node }) => (
<CartLineItem
key={node.id}
item={node}
onUpdateQty={(qty) => updateLines([{ id: node.id, quantity: qty }])}
onRemove={() => removeLines([node.id])}
/>
))}
</View>
);
}