diff --git a/package.json b/package.json index 5ae880e..442ab43 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/ConfigCatProvider.tsx b/src/ConfigCatProvider.tsx index d32b877..c7ce9d2 100644 --- a/src/ConfigCatProvider.tsx +++ b/src/ConfigCatProvider.tsx @@ -21,7 +21,7 @@ type ConfigCatProviderState = { }; class ConfigCatProvider extends Component< -/* eslint-disable @typescript-eslint/indent */ + /* eslint-disable @typescript-eslint/indent */ PropsWithChildren, ConfigCatProviderState, {} @@ -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() }); }