newbie
I can create an element but how do I then add to that element ?
When I try
<body>
React....
<div id="main_insert">
<span>
</span>
</div>
<script src="https://unpkg.com/[email protected]/dist/react.js"></script>
<script src="https://unpkg.com/[email protected]/dist/react-dom.js"></script> <script>
let dish = React.createElement("h1", {id: 'top'}, "Baked Salmon");
let ingredients = React.createElement("ul", {id: 'mainList'},
React.createElement("li", null, "eggs"),
React.createElement("li", null, "ham"),
React.createElement("li", null, "spam")
);
ReactDOM.render(dish, document.getElementById('main_insert'));
ReactDOM.render(ingredients, document.getElementById('top'));
// react and js code here
</script>
</body>
I get the ingredients but not the dish
My H1 does exist, but content is gone




ReactDOM.renderworks internally. If we comment the second render statement,h1tag data gets displayed properly. Now, since the list is getting displayed inside thish1tag, it does not take into account the data that was initially present within theh1. Same can be verified by having some content within the main_insertdivand then trying to render only theh1. In this case also content within the main_insertdivdisappears.