As far as I can tell, this is the only way to do what you ask for (since I tried to do the same):
let divs = document.getElementsByClassName("some_class")
for (let i = 0; i < divs.length; i++) {
const id = Math.random()
const d = document.createElement("div")
d.id = id
divs[i].appendChild(d)
ReactDOM.render(<SomeComponent/>, document.getElementById(id))
}
If anyone knows of a cleaner / improved way to add a component reactto an existing one <div>without first installing a new empty one <div>, please call!
source
share