From 76973910e99765195af2b8cdcbc0d7aba2feffa5 Mon Sep 17 00:00:00 2001 From: "Mr.Hope" Date: Fri, 21 Apr 2023 14:07:54 +0800 Subject: [PATCH] feat(client): add overrideExisting arg --- packages/client/src/helpers/defineClientData.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/client/src/helpers/defineClientData.ts b/packages/client/src/helpers/defineClientData.ts index 9f11a2f2a3..cc71048590 100644 --- a/packages/client/src/helpers/defineClientData.ts +++ b/packages/client/src/helpers/defineClientData.ts @@ -7,7 +7,8 @@ export const clientDataMap = new Map, unknown>() */ export const defineClientData = ( key: InjectionKey, - data: T + data: T, + overrideExisting = true ): void => { - clientDataMap.set(key, data) + if (overrideExisting || !clientDataMap.has(key)) clientDataMap.set(key, data) }