I have an array of strings and I'm trying to render it inside a component with react js
this array of comments is inside my Posts
comentarios = ["test1", "test2", "test3","test4"] note: I'm taking this array from firebase documents
I can render it but I have a problem. when I render by map () this array returns me all the items in a single line. I researched some resolutions for this problem here in the community and on google, I found this topic: How to display an array of strings in react component
even so, I was unable to resolve it definitively.
my question is: how do i return each index of the array within its own paragraph?
constructor(props) {
super(props);
this.state = {
Posts: [],
}
<div className="text-comentarios">
{this.state.Posts.map( (itens,index) =>{
<div>
<p key={index}> {itens.comentarios} </p>
</div>
)
})}
</div>
I am have the return of this map as follows:
Coments: test1test2test3test4
how do i get this return, example:
Coments: test1
Coments: test2
Coments: test3
Coments: test4