From b1276cfcd598ae17a368bb0b4fdf542c1c184d24 Mon Sep 17 00:00:00 2001 From: Erik Engervall Date: Mon, 5 Feb 2024 17:56:57 +0900 Subject: [PATCH] feat(medusa-react): Add medusaClient prop to MedusaProvider (#6299) --- packages/medusa-react/src/contexts/medusa.tsx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/medusa-react/src/contexts/medusa.tsx b/packages/medusa-react/src/contexts/medusa.tsx index 7a14831dd619c..e28af8f8dc76f 100644 --- a/packages/medusa-react/src/contexts/medusa.tsx +++ b/packages/medusa-react/src/contexts/medusa.tsx @@ -99,6 +99,10 @@ export interface MedusaProviderProps { * @defaultValue `{}` */ customHeaders?: Record + /** + * An instance of the Medusa JS Client. If you don't provide an instance, one will be created using the `baseUrl`, `apiKey`, `publishableApiKey`, `maxRetries`, and `customHeaders` props. + */ + medusaClient: Medusa } /** @@ -144,14 +148,14 @@ export const MedusaProvider = ({ customHeaders, maxRetries = 3, children, -}: MedusaProviderProps) => { - const medusaClient = new Medusa({ + medusaClient = new Medusa({ baseUrl, maxRetries, apiKey, publishableApiKey, customHeaders, - }) + }), +}: MedusaProviderProps) => { return (