I have a React function where I am having a set and I want to update an HTML element using the data present in the set. Following is the code example:
const myFunc = (mySet) => {
document.getElementById('myId').innerHTML = Array.from(mySet).join(' ');
}
...
// In the render code:
<p id="myId> </p>
This correctly joins the set elements using a blank space separator, but I want to have it displyed in the form of bulleted lists or in a new line.
Is it possible to have multiline append using innerHTML?
Ex: mySet = ('Apple', 'Banana', 'Carrot', 'Drumstick')
Output on my code: Apple Banana Carrot Drumstick
Output desirable:
Apple
Banana
Carrot
Drumstick
(or)
- Apple
- Banana
- Carrot
- Drumstick