Skip to content
This repository has been archived by the owner on Oct 1, 2023. It is now read-only.

Warning: Encountered two children with the same key #44

Open
alexanderbrodko opened this issue Feb 24, 2023 · 1 comment
Open

Warning: Encountered two children with the same key #44

alexanderbrodko opened this issue Feb 24, 2023 · 1 comment
Labels
bug Something isn't working question Further information is requested
Milestone

Comments

@alexanderbrodko
Copy link

On codesandbox, there is a huge amount of warnings looking as follow:

Warning: Encountered two children with the same key, 'https://codesandbox.io/_next/image?url=%2F_next%2Fstatic%2Fmedia%2Fimage.2b1cff1a.gif&w=3840&q=75'. Keys should be unique so that components maintain their identity across updates. Non-unique keys may cause children to be duplicated and/or omitted — the behavior is unsupported and could change in a future version.
    at span
    at span
    at div
    at div
    at Carousel (https://zmbhw7.csb.app/node_modules/bearing/dist/index.js:105:18)
    at div
    at App (https://zmbhw7.csb.app/src/App.tsx:55:32)
@rosingrind rosingrind added the bug Something isn't working label Feb 24, 2023
@rosingrind
Copy link
Owner

URL of slide is used as the key parameter in next lines:

<Slide
key={s}
src={s}
animation={animation}
offset={key}
move={move}
len={slides.length}
size={size}
/>

<button type="button" key={i} className={cns.dot(key === current)} onClick={() => getPos(key)}>

This leads to producing these warnings as slides contain an array of same strings. As a solution to this issue, either key should contain source strings with hash appended, or refactoring of render system should be considered as option. These warnings are emitted each animation cycle, so may be the fundamental issue taking place there

@rosingrind rosingrind added the question Further information is requested label Feb 24, 2023
@rosingrind rosingrind added this to the 0.9.0 milestone Feb 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants