Everyone know this error: Each child in a list should have a unique "key" prop
But what if I have array of strings that I want to render in my paragraph with
at the end?
return(
<p>
{array.map(string => {
return <>{string}<br/></>
})}
</p>
)
As you can see I'm literally returning only text with <br/>
at the end, I don't have place or need for a key. How can I get rid of this error? Wrapping every phrase in <span>
is not an option.
<br />
here? Depending on what you're doing, maybe drop thep
and use aul
orli
which is the correct semantic for lists of items. See this – ggorlen Dec 3 '20 at 22:39<br/>
. I don't want react to listen to it, since I'm literally printing several lines into same paragraph. – Alyona Dec 4 '20 at 7:55