From 9577f33b709157babbe744a6bc6d92534cff762f Mon Sep 17 00:00:00 2001 From: adams85 <31276480+adams85@users.noreply.github.com> Date: Tue, 4 Feb 2025 13:33:05 +0100 Subject: [PATCH] Prevent unwanted dispose in development when Strict Mode is enabled (#68) * Prevent unwanted dispose in development when Strict Mode is enabled (https://github.com/configcat/react-sdk/issues/67) * Suggestion on making the ConfigCatClient reference tracking a bit more robust * Bump version --- package-lock.json | 4 ++-- package.json | 2 +- src/ConfigCatProvider.tsx | 25 +++++++++++-------------- 3 files changed, 14 insertions(+), 17 deletions(-) diff --git a/package-lock.json b/package-lock.json index db9be65..1c212c7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "configcat-react", - "version": "4.8.0", + "version": "4.8.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "configcat-react", - "version": "4.8.0", + "version": "4.8.1", "license": "MIT", "dependencies": { "configcat-common": "9.3.1", diff --git a/package.json b/package.json index 4f283b9..3278a8d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "configcat-react", - "version": "4.8.0", + "version": "4.8.1", "scripts": { "build": "npm run build:esm && npm run build:cjs", "build:esm": "tsc -p tsconfig.build.esm.json && gulp esm", diff --git a/src/ConfigCatProvider.tsx b/src/ConfigCatProvider.tsx index fefbbd6..f14b21f 100644 --- a/src/ConfigCatProvider.tsx +++ b/src/ConfigCatProvider.tsx @@ -18,7 +18,9 @@ type ConfigCatProviderProps = { type ConfigCatProviderState = ConfigCatContextData; -const initializedClients = new Map(); +type AugmentedConfigCatClient = IConfigCatClient & { + $reactSdk_providers?: Set; +} class ConfigCatProvider extends Component, ConfigCatProviderState, {}> { private configChangedHandler?: (newConfig: IConfig) => void; @@ -26,18 +28,18 @@ class ConfigCatProvider extends Component this.reactConfigChanged(newConfig); this.state.client.waitForReady().then(() => { @@ -56,14 +58,9 @@ class ConfigCatProvider extends Component