CartLineProvider Component
The CartLineProvider component creates a context for using a cart line, allowing components to access the CartLine object from the Storefront API.
Usage
import React from "react";
import { CartLineProvider } from "@airsoko/react";
import { CartItem } from "@airsoko/graphql/api-types";
const MyComponent = () => {
const cartLine: CartItem = {
// CartItem properties
};
return <CartLineProvider line={cartLine}>{/* Your component content */}</CartLineProvider>;
};
export default MyComponent;Props
| Name | Type | Description |
|---|---|---|
children | ReactNode | Any ReactNode elements. |
line | CartLine | A cart line object, which is a partial deep object of the CartItem from the Storefront API. |
Notes
- Wrap your component with
CartLineProviderto provide access to the cart line context. - Ensure that the
lineprop passed toCartLineProvideris aCartLineobject, which is a partial deep object of theCartItemfrom the Storefront API. - Use the
useCartLinehook within your components to access the cart line context.