I am trying to include Google Adsense in a React component using 'react-adsense'.
I have followed the creator's instructions here.
I am getting the following error:
{message: 'adsbygoogle.push() error: No slot size for availableWidth=0', name: 'TagError', pbr: true, stack: 'TagError: adsbygoogle.push() error: No slot size f…oogle.js?client=ca-pub-1034524975771842:102:1098)'}
I have looked into this error and tried the suggestions here, here, and here.
From what I can tell it has something to do with a parent div's width. I've gone through and made sure everything has a set width but no luck. Am I overlooking something super obvious??
REACT COMPONENT
import React from 'react';
import '../styles/ads.css';
import AdSense from 'react-adsense';
const Ads = () => {
return (
<div className='ads'>
<AdSense.Google
client='ca-pub-1034524975771842'
slot='3468851388'
style={{ display: 'block' }}
format='auto'
responsive='true'
layoutKey='-gw-1+2a-9x+5c'
/>
</div>
);
};
export default Ads;
APP.JS
import './styles/app.css';
import React from 'react';
import Ads from './components/Ads';
function App() {
return (
<div className='app'>
<Ads />
</div>
);
}
export default App;