From ab9eee465bf3272f8e18133cf605415ae1832414 Mon Sep 17 00:00:00 2001 From: Lajos Szoke <63732287+laliconfigcat@users.noreply.github.com> Date: Wed, 26 Apr 2023 08:33:07 +0200 Subject: [PATCH] fix user state (#28) * fix user state * v2.3.0 * stringify --- package-lock.json | 4 ++-- package.json | 2 +- src/ConfigCatHooks.tsx | 5 ++--- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index b0f0190..f159419 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "configcat-react", - "version": "2.2.1", + "version": "2.3.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "configcat-react", - "version": "2.2.1", + "version": "2.3.0", "license": "MIT", "dependencies": { "configcat-common": "^7.0.1", diff --git a/package.json b/package.json index b3c5c77..19b9a2b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "configcat-react", - "version": "2.2.1", + "version": "2.3.0", "scripts": { "build": "npm run build:esm && npm run build:cjs", "build:esm": "tsc -p tsconfig.build.esm.json && gulp esm", diff --git a/src/ConfigCatHooks.tsx b/src/ConfigCatHooks.tsx index 6fe5539..b1765af 100644 --- a/src/ConfigCatHooks.tsx +++ b/src/ConfigCatHooks.tsx @@ -12,12 +12,11 @@ function useFeatureFlag(key: string, defaultValue: any, user?: User | undefined) const [featureFlagValue, setFeatureFlag] = useState(defaultValue); const [loading, setLoading] = useState(true); - const [userState] = useState(user); useEffect(() => { - configCatContext.client.getValueAsync(key, defaultValue, userState) + configCatContext.client.getValueAsync(key, defaultValue, user) .then(v => { setFeatureFlag(v); setLoading(false); }); - }, [configCatContext, key, defaultValue]); + }, [configCatContext, key, defaultValue, JSON.stringify(user)]); return { value: featureFlagValue, loading }; }