D
D
Dmitry Mukhin2020-04-19 01:34:40
React
Dmitry Mukhin, 2020-04-19 01:34:40

How to insert outer div in React?

There are various services (designers of forms and surveys) that say that you need to insert their script and some kind of div into the site in order to form dynamic elements in it ( ) I have a BrowserRouter that leads to the /contact page. And it turns out that my SPA first renders the main one, and when you click on the link, it gets to the desired page, but this div does not work there. When the /contact page is updated, this div is formed, or if you write it on the main page, then everything works. The outer script doesn't see the div initially, and then it's too late. As I understand it, I need to dig towards componentDidMount(), but I don't understand how. <div id="999" data-id="999"></div>

Answer the question

In order to leave comments, you need to log in

3 answer(s)
H
hzzzzl, 2020-04-19
@hzzzzl

https://stackoverflow.com/a/34425083

M
McBernar, 2020-04-19
@McBernar

You need to either manually include it by creating a script node, or access the script in the component through window if it has an api.
React often makes adaptations. Maybe in your case too.

@
@Predaytor, 2020-04-19
_

ReactDOM.createPortal

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question