Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InfiniteScroller console warning about unique key #562

Closed
mareklibra opened this issue Apr 10, 2018 · 7 comments · Fixed by #616
Closed

InfiniteScroller console warning about unique key #562

mareklibra opened this issue Apr 10, 2018 · 7 comments · Fixed by #616
Labels
Milestone

Comments

@mareklibra
Copy link
Contributor

mareklibra commented Apr 10, 2018

Console log shows

VM27174 warning.js:33 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 Vms. See https://fb.me/react-warning-keys for more information.
    in div (created by Vms)
    in InfiniteScroll (created by Vms)
    in Vms (created by Connect(Vms))
    in Connect(Vms) (created by VmsList)
    in VmsList (created by Connect(VmsList))

Works fine anyway, lower priority to make code clean.

@mareklibra mareklibra added this to the v1.4.0 milestone Apr 10, 2018
sjd78 added a commit to sjd78/ovirt-web-ui that referenced this issue May 22, 2018
1. Fixes oVirt#562 as per
   https://github.com/CassetteRocks/react-infinite-scroller/issues/133.
   Added `key={0}` to the loader and the InfiniteScroller warning went away.

2. Added an `all([])` wrapper around the rootSaga to resolve the deprecation
   warning.

3. Refactored `VmDetail/index.js` to add `key={0}` to the React.Fragment
   use as it was causing a warning similar to InfiniteScroller's warning.
sjd78 added a commit to sjd78/ovirt-web-ui that referenced this issue May 23, 2018
1. Fixes oVirt#562 as per
   https://github.com/CassetteRocks/react-infinite-scroller/issues/133.
   Added `key={0}` to the loader and the InfiniteScroller warning went away.

2. Added an `all([])` wrapper around the rootSaga to resolve the deprecation
   warning.

3. Refactored `VmDetail/index.js` to add `key={0}` to the React.Fragment
   use as it was causing a warning similar to InfiniteScroller's warning.
sjd78 added a commit to sjd78/ovirt-web-ui that referenced this issue May 24, 2018
1. Fixes oVirt#562 as per
   https://github.com/CassetteRocks/react-infinite-scroller/issues/133.
   Added `key={0}` to the loader and the InfiniteScroller warning went away.

2. Added an `all([])` wrapper around the rootSaga to resolve the deprecation
   warning.

3. Refactored `VmDetail/index.js` to add `key={0}` to the React.Fragment
   use as it was causing a warning similar to InfiniteScroller's warning.
atiratree pushed a commit to atiratree/ovirt-web-ui that referenced this issue May 24, 2018
1. Fixes oVirt#562 as per
   https://github.com/CassetteRocks/react-infinite-scroller/issues/133.
   Added `key={0}` to the loader and the InfiniteScroller warning went away.

2. Added an `all([])` wrapper around the rootSaga to resolve the deprecation
   warning.

3. Refactored `VmDetail/index.js` to add `key={0}` to the React.Fragment
   use as it was causing a warning similar to InfiniteScroller's warning.
@mohammad-khoddami
Copy link

Add key={0} to the loader fix it. see
#616 (comment)

@arhamymr
Copy link

arhamymr commented Sep 2, 2020

hello, i add key to infinite

 <InfiniteScroll
        hasMore={hasMore}
        loader={<div key={0}/>}
        loadMore={loadFunc}
        pageStart={0}
      >

and still have warning in console, someone can help me ?

@nateg101
Copy link

nateg101 commented Sep 8, 2020

Yes I too have the same problem - I am using V1.2.4

@sgratch
Copy link
Member

sgratch commented Sep 23, 2020

@nateg101 @arhamymr this is an old issue. Is it reproduced for you on latest version 1.6.4 as well?

@Poem7200
Copy link

Anybody still come out with the same issue? I use version 1.2.6 and there is still the same warning…

@frodolfo-duclo
Copy link

Anybody still come out with the same issue? I use version 1.2.6 and there is still the same warning…

I also have this issue with version 1.2.6, and it's May 2023 now.

@Ruffeng
Copy link

Ruffeng commented Feb 28, 2024

If someone is facing this issue, make sure you wrap your component with a div and key:

loader={
  <div key={0}>
    <MyLoaderComponent />
  </div>
}

I was having this warning as well because the key was inside my component, but moving it in the same place as the loader prop solved the issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants