diff --git a/package.json b/package.json index 010629e..05d4d4d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-advertising", - "version": "4.2.8", + "version": "4.2.9", "description": "Library for display ads in React applications", "main": "lib/index.js", "unpkg": "dist/react-advertising.min.js", diff --git a/src/components/AdvertisingProvider.js b/src/components/AdvertisingProvider.js index 88ea7de..dec30de 100644 --- a/src/components/AdvertisingProvider.js +++ b/src/components/AdvertisingProvider.js @@ -13,6 +13,7 @@ export default class AdvertisingProvider extends Component { this.state = { activate: this.advertising.activate.bind(this.advertising), config: this.props.config, + isInitialSetupComplete: false, }; } @@ -66,7 +67,11 @@ export default class AdvertisingProvider extends Component { } async componentWillUnmount() { - if (this.props.config) { + /** + * Prevent the teardown call while initial setup still in progress + * otherwise it can create a race condition that breaks the setup process + */ + if (this.props.config && this.state.isInitialSetupComplete) { await this.teardown(); } }