How can I iteratively render nested components in react?
(as I understood, recursion is more expensive in terms of performance?)
P.S. nesting levels can be unlimited
Example:
"comments": [
{
"name": "1comment",
"body": "1comment",
"date": "2019-05-15T15:56:15.694116Z",
"id": "0179ef41-fdb6-4700-a4dc-6d7bbc54385a",
"parent": null,
"reply": []
},
{
"name": "2comment",
"body": "2comment",
"date": "2019-05-17T13:59:51.167188Z",
"id": "1ef06878-58b5-48b0-9349-73986ab66bb4",
"parent": null,
"reply": [
{
"name": "2-1-comment",
"body": "2-1-comment",
"date": "2019-05-21T22:32:44.998207Z",
"id": "514aa634-08bd-4ca3-8a1a-eb10846808ed",
"parent": "5a01211d-3ee9-4bf6-9a50-462a8277898a",
"reply": [
{
"name": "2-1-1-comment",
"body": "2-1-1-comment",
"date": "2019-05-21T22:32:44.998207Z",
"id": "514aa634-08bd-4ca3-8a1a-eb10846808ed",
"parent": "5a01231d-3119-4bf6-9a50-462a8277898a",
"reply": []
}
]
}
]
},
{
"name": "3comment",
"body": "3comment",
"date": "2019-05-19T12:07:15.613266Z",
"id": "5a01231d-3ee9-4bf6-9a50-462a8277898a",
"parent": null,
"reply": [
{
"name": "3-1-comment",
"body": "3-1-comment",
"date": "2019-05-21T22:32:44.998207Z",
"id": "514aa634-08bd-4ca3-8a1a-eb10846808ed",
"parent": "5a01231d-3ee9-4bf6-9a50-462a8277198a",
"reply": []
}
]
}
]