Skip to content

Commit

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

* unnecessary import
  • Loading branch information
laliconfigcat authored Mar 7, 2023
1 parent 20f6bd1 commit 02fd55b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
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.0.0",
"version": "2.1.0",
"scripts": {
"build": "npm run build:esm && npm run build:cjs",
"build:esm": "tsc -p tsconfig.build.esm.json && gulp esm",
Expand Down
10 changes: 9 additions & 1 deletion src/ConfigCatProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type ConfigCatProviderState = {
};

class ConfigCatProvider extends Component<
/* eslint-disable @typescript-eslint/indent */
/* eslint-disable @typescript-eslint/indent */
PropsWithChildren<ConfigCatProviderProps>,
ConfigCatProviderState,
{}
Expand Down Expand Up @@ -62,10 +62,18 @@ class ConfigCatProvider extends Component<
}

reactConfigChanged(newConfig: ProjectConfig): void {
if (!this.state) {
// Initialization phase will set state anyway.
return;
}
this.setState({ lastUpdated: new Date(newConfig.Timestamp) });
}

clientReady(): void {
if (!this.state) {
// Initialization phase will set state anyway.
return;
}
this.setState({ lastUpdated: new Date() });
}

Expand Down

0 comments on commit 02fd55b

Please sign in to comment.