Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

113
Views
Chakra UI unique key prop

I am using @chakra-ui/react version 1.7.2 in my React 17.0.2 project.

This version of Chakra UI is supposed to have solved the issue of having unique keys in its elements, but I am still having the error when I test the code and in Chrome's console:

"Each child in a list should have a unique "key" prop."

Adding a unique "key" prop manually doesn't solve the issue. Any suggestions?

    const MyComponent = () => {
        const myArray = ['London', 'Paris'];
        
        return (
          <List>
            {myArray.map(city => (
                <ListItem key={city}>
                  <b>{city}</b>
                </ListItem>
              )
            )}
          </List>
        )
    };
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

if you have id in side the city object assign that like city.id etc. if not you can assign some unique string on the city object that is being returned. The only last resort is to use the index number of the item (it is not suggested but you can use it.). See the code below:

      <List>
        {myArray.map((city, index) => (
            <ListItem key={index}>  <=========== (you can use city.<some_unique_id_here>)
              <b>{city}</b>
            </ListItem>
          )
        )}
      </List>
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!