question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Keys warning in the console

See original GitHub issue

Hi Guys,

I am getting the following error in the console:

index.js:2178 Warning: Each child in an array or iterator should have a unique "key" prop.

Check the render method of `InfiniteScroll`. It was passed a child from . See https://fb.me/react-warning-keys for more information.

I have no idea why. Any ideas?

return (
      //Implement pagination using infinite scroll
      <div {...s('wrapper')}>
        <InfiniteScroll
          pageStart={0}
          loadMore={this.loadMoreRestaurants}
          hasMore={loadmore}
          loader={<LoadingSpinner />}
        >
          <div {...s('restaurants')}>
            {restaurantList.map(({ restaurant }) => (
              <RestaurantCard key={restaurant.id} restaurant={restaurant} />
            ))}
          </div>
        </InfiniteScroll>
      </div>
    );

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:3
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

29reactions
danboveycommented, Apr 22, 2018

You need to add a unique key prop onto the loader.

return (
      //Implement pagination using infinite scroll
      <div {...s('wrapper')}>
        <InfiniteScroll
          pageStart={0}
          loadMore={this.loadMoreRestaurants}
          hasMore={loadmore}
          loader={<LoadingSpinner key={0} />} // <-- Added key={0}
        >
          <div {...s('restaurants')}>
            {restaurantList.map(({ restaurant }) => (
              <RestaurantCard key={restaurant.id} restaurant={restaurant} />
            ))}
          </div>
        </InfiniteScroll>
      </div>
    );
3reactions
luq10commented, Jan 3, 2020

@danbovey Can you say why this is needed?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Warning console : Each child in a list should have a unique ...
I want to correct the warning "Each child in a list should have a unique" key "prop" in the console. I tried adding...
Read more >
Generate Security Keys warning on Storefront management ...
This indicates that the Self-Signed certificates generated by storefront are expired and they needs to be renewed. You can see the certificates from...
Read more >
Encountered Two Children with the Same Key — React Fix
Warning: Encountered two children with the same key, [object Object]. Keys should be unique so that components maintain their identity across ...
Read more >
Silence noisy missing-key warning when it doesn't apply #12567
I'd like to request a feature that would enable us to silence the missing-key warning (https://fb.me/react-warning-keys) since it doesn't apply ...
Read more >
How to resolve React console warnings about unique `key ...
After opening up the console in the browser dev tools while working on a Dash app, I noticed I was getting the following...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found