Skip to content

Commit

Permalink
fix user state (#28)
Browse files Browse the repository at this point in the history
* fix user state

* v2.3.0

* stringify
  • Loading branch information
laliconfigcat authored Apr 26, 2023
1 parent e7abeb9 commit ab9eee4
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
5 changes: 2 additions & 3 deletions src/ConfigCatHooks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
}
Expand Down

0 comments on commit ab9eee4

Please sign in to comment.