Packages
react
providers
CartLineProvider

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

NameTypeDescription
childrenReactNodeAny ReactNode elements.
lineCartLineA cart line object, which is a partial deep object of the CartItem from the Storefront API.

Notes

  • Wrap your component with CartLineProvider to provide access to the cart line context.
  • Ensure that the line prop passed to CartLineProvider is a CartLine object, which is a partial deep object of the CartItem from the Storefront API.
  • Use the useCartLine hook within your components to access the cart line context.