Q:

Google Auto-ads on React.js application?

I have a website front-end running on React.js. 
I have added the following line to index.html's head tag.
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>

The following code presents me with the error, "'adsbygoogle' is not defined  no-undef"
componentDidMount () {
        (adsbygoogle = window.adsbygoogle || []).push({
              google_ad_client: "ca-pub-9142841210062390",
              enable_page_level_ads: true
         });
}

How can I get advertisements to display on my React.js web application? 
This is with Google Auto Ads, not ad units.

A:

You have to write "window.adsbygoogle" in reactjs application instead of "adsbygoogle"
componentDidMount () {
    (window.adsbygoogle = window.adsbygoogle || []).push({
          google_ad_client: "ca-pub-9142841210062390",
          enable_page_level_ads: true
     });
}

