Check out example codes for "js remove all child elements from html". It will help you in understanding the concepts better.
Code Example 1
document.getElementById("myId").innerHTML = '';
Code Example 2
while (myNode.firstChild) {
myNode.removeChild(myNode.lastChild);
}
Code Example 3
// Get the <ul> element with id="myList"
let list = document.getElementById("myList");
// As long as <ul> has a child node, remove it
while (list.hasChildNodes()) {
list.removeChild(list.firstChild);
}
Learn ReactJs, React Native from akashmittal.com