I have an array of comments which can have answers, so every element (comment) of the array can have nested elements (comments) and the nesting level is unknown, but I need to render this array in ReactJs to display these comments with the given nesting level.
comment 1
-- comment 2
-- comment 3
---- comment 4
-- comment 5
comment 6
-- comment 7
Something like this. But I have no idea how to do this.
I would like to see an example how to render it with ReactJs, but an example how to map such arrays in JavaScript would be helpful as well.
My array is more complex then an array of strings, but let's imagine that this is like
[
{
"value": "awesome",
"comments": [
{
"value": "thanks"
"comments": null
},
{
"value": "really awesome",
"comments": [
"value": "thanks again",
"comments": null
]
}
]
}
]
I hope this example will help.