I found this component
import React, { useEffect } from 'react';
const AdsComponent = (props) => {
const { dataAdSlot } = props;
useEffect(() => {
try {
(window.adsbygoogle = window.adsbygoogle || []).push({});
}
catch (e) {
}
},[]);
return (
<>
<ins className="adsbygoogle"
style={{ display: "block" }}
data-ad-client="ca-pub-XXXXXXXXXXXXXXX"
data-ad-slot={dataAdSlot}
data-ad-format="auto"
data-full-width-responsive="true">
</ins>
</>
);
};
export default AdsComponent;
Or just add the script tag in head?
<head>
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-1234567890123456" crossorigin="anonymous"></script>
This is the head of your page.
<title>Example HTML page</title>
</head>