ProductProvider
The ProductProvider
component sets up a context with state that tracks the selected variant and options. Descendants of this component can use the useProductOptions
hook.
Example code
Anchor link to section titled "Example code"
Name | Type | Description |
---|---|---|
children | ReactNode |
A ReactNode element. |
data | PartialDeep<ProductType> |
An object with fields that correspond to the Storefront API's Product object. |
initialVariantId? | Parameters<typeof useProductOption>['0']['initialvariantid'] |
The initially selected variant. The following logic applies to initialVariantId :
|
Component type
Anchor link to section titled "Component type"The ProductProvider
component is a client component, which means that it renders on the client. For more information about component types, refer to React Server Components.