I am trying to insert ajax response to body from page that has React JS.
The page has only div and script tag like below;
<div data-react-class="example" data-react-props="{}" data-react-cache-id="example-0" class="example"></div>
<script type="text/javascript" src="/packs/js/application.js"></script>
I tried document.body.append, document.write, document.body.innerHTML +=... or insert div and script separately but React Component not initialized. All methods I tried that inserting code but React JS not activated.
I tried setTimeout for script but nothing changed. Although when I open the page without ajax it works as I expected.
What am I missing?
How can I initialize React JS after insert to page with javascript.
Code Example: https://codesandbox.io/embed/awesome-roentgen-q9m0b
Works without ajax: https://q9m0b.csb.app/src/get-ajax-page.html
But does not initialize if I insert with ajax: https://q9m0b.csb.app/