How to tie Yan to reactjs?

Yandex generates this code for your ad. How to tie reactjs?
<!-- Yandex.RTB XXXXX -->
<div id="yandex_rtb_XXXXXX"></div>
<script type="text/javascript">
 (function(w, d, n, s, t) {
 w[n] = w[n] || [];
 w[n].push(function() {
Ya.Context.AdvManager.render({
 blockId: "XXXXXX",
 renderTo: "yandex_rtb_XXXXXXX",
 horizontalAlign: false,
 async: true
});
});
 t = d.getElementsByTagName("script")[0];
 s = d.createElement("script");
 s.type = "text/javascript";
 s.src = "//an.yandex.ru/system/context.js";
 s.async = true;
 t.parentNode.insertBefore(s, t);
 })(this, this.document, "yandexContextAsyncCallbacks");
</script>
June 27th 19 at 15:31
1 answer
June 27th 19 at 15:33
just paste in your html, below the diva, which is rendered to react, react because "differ" only the entry-node you specified.

if you want to add in reacte from under the component, it is possible

appendYaMetrix() {
 const yaDiv = document.createElement('div')
 yaDiv.setAttribute('id', 'yandex_rtb_XXXXXX')
document.body.appendChild(yaDiv)

 const yaScript = document.createElement('script')
 yaScript.setAttribute('type', 'text/javascript')
 yaScript.innerHTML = `(function(w, d, n, s, t) {
 w[n] = w[n] || [];
 w[n].push(function() {
Ya.Context.AdvManager.render({
 blockId: "XXXXXX",
 renderTo: "yandex_rtb_XXXXXXX",
 horizontalAlign: false,
 async: true
});
});
 t = d.getElementsByTagName("script")[0];
 s = d.createElement("script");
 s.type = "text/javascript";
 s.src = "//an.yandex.ru/system/context.js";
 s.async = true;
 t.parentNode.insertBefore(s, t);
 })(this, this.document, "yandexContextAsyncCallbacks");`

document.head.appendChild(yaScript)
}

componentDidMount() {
this.appendYaMetrix()
}

Find more questions by tags ReactYandex