I need to render a list with string items like ['a', 'b', 'c', 'a'], the items are allowed to be duplicate to each other, what is the proper way to choose a react key in {list.map(x => <span key={?}>{x}</span>)}?
This should work
{list.map((x,i) => <span key={`${x}-${i}`}>{x}</span>)}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With