From 0e35bca1609fba9dbd8411ab110316c9bb8cc57f Mon Sep 17 00:00:00 2001 From: Andrew Berry Date: Thu, 17 Jan 2019 17:27:57 -0500 Subject: [PATCH] fix: Fix undefined function if apiNotReady (#6) Fix undefined function if apiNotReady. Cribbed from https://github.com/ticketmaster/react-gpt/commit/5ef19b1b394ced358a555f7844885e056f71bc16. --- src/Bling.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/Bling.js b/src/Bling.js index b4edea0..4254ebb 100644 --- a/src/Bling.js +++ b/src/Bling.js @@ -553,13 +553,15 @@ class Bling extends Component { defineSizeMapping(adSlot, sizeMapping) { if (sizeMapping) { - Bling._adManager.addMQListener(this, this.props); - const sizeMappingArray = sizeMapping - .reduce((mapping, size) => { - return mapping.addSize(size.viewport, size.slot); - }, Bling._adManager.googletag.sizeMapping()) - .build(); - adSlot.defineSizeMapping(sizeMappingArray); + Bling._adManager.googletag.cmd.push(() => { + Bling._adManager.addMQListener(this, this.props); + const sizeMappingArray = sizeMapping + .reduce((mapping, size) => { + return mapping.addSize(size.viewport, size.slot); + }, Bling._adManager.googletag.sizeMapping()) + .build(); + adSlot.defineSizeMapping(sizeMappingArray); + }); } }