-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[CarouselIndicators] Warning: Encountered two children with the same key #1310
Comments
See here: CarouselIndicators.js Check out the line 16 - it's the one that builds the key prop for each indicator. If a const items = [
{
'key': 0,
'foo': 'bar',
},
{
'key': 1,
'foo': 'bahr',
}
] The resulting keys look something like |
It's the same approach as What if we could pass a chosen key to look for as props to CarouselIndicator. And then it will look for it instead of relying on the fact that the user will have a dataset which will match the one Such as
So the implementation would look like
|
Something like this. Making it optional by default |
I think just concatenating whatever values are passed in the item objects would be less painful. No change needed to the docs, no logic required. Only stuff passed to the items prop that's unique. Hopefully the PR is accepted, or at least we find a way to fix the issue if my solution isn't the way to go. |
…1311) Generation of key items for `li` components in `CarouselIndicators` is a concatenation of specific, optional values (`src`, `caption`, and `altText`) in each item of the `items` object array. Lacking these key/value pairs will cause each `li` element to have a key along the lines of `undefinedundefinedundefined`, resulting two or more of the `li`'s to be identical and causing an error to log in the console. While either including any one of the specified keys with a unique value, or adding a unique `key` field in each of the items objects will remedy this issue, that solution is not well documented. The proposed solution is a transparent fix: preventing the aforementioned error while requiring no change of code for the end-user. The new `key` prop value for each `li` will be a concatenation of all the values of its respective item object. Closes #1310
CarouselIndicators
^6.1.0
^16.4.1
^4.1.0
What is happening?
When you pass your data to
It provoke
What should be happening?
CarouselIndicators shouldn't rely on dataset implementation (which is not using src)
Error message in console
Code
The text was updated successfully, but these errors were encountered: