1.2 KiB
1.2 KiB
The useCartLinesRemoveCallback
hook returns a callback that can be used to remove lines from a cart. It must be a descendent of a CartProvider
component.
Example code
import {useCartLinesRemoveCallback} from '@shopify/hydrogen';
export function RemoveFromCartButton({lineId}) {
const removeLines = useCartLinesRemoveCallback();
return (
<button
onClick={() => {
removeLines([lineId]);
}}
>
Remove from cart
</button>
);
}
Return value
A callback to remove lines from a cart. The callback expects one argument that corresponds to the input you would provide to the Storefront API's cartLinesRemove
mutation.