On the initial page load of the page I have a list of users
<div class="user"></div>
<div class="user"></div>
<div class="user"></div>
I replace the content with React components:
const buildElement = React.createElement;
let domElements = document.getElementsByClassName('user');
for(let domContainer of domElements) {
ReactDOM.render(buildElement(UserDetails, {
...
}), domContainer);
}
All works fine so far. However, if I dynamically load new users, they are not picked up by React. For example, if I do
$("#users").append("<div class='user'></div>")
How could I render the React component inside the dynamically added user div :? Thanks!
EDIT: With the current setup of the application, it is not possible to simply render the users using React...
<user/>instead of div? developer.mozilla.org/en-US/docs/Web/API/Window/customElements