Ravenous Project: part 2 (Warning: Each child in a list should have a unique "key" prop)

part 2 is working, but gives me this error

Hi,
I got the exactly same Warning code.
I tried to resolve the issue.
The Warning(this is not an error) occured in the BusinessList.js file:
My first code was:

{
     this.props.businesses.map((business, index) => 
          <Business business={business}/>)
}

I needed to add a unique key property to the (Business /) and it is resolve the issue.

Solution
{
      this.props.businesses.map((business, index) => 
           <Business key={index} business={business}/>)
}
1 Like

React always expects every list to have a key prop passed into it, iā€™d use the index of the map function