Skip to content

Fix component as props used in the same container getting the same key #3284

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

Merged
merged 3 commits into from
Apr 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ This project adheres to [Semantic Versioning](https://semver.org/).
## Fixed
- [#3278](https://github.com/plotly/dash/pull/3278) Fix loading selector with children starting at the same digit. Fix [#3276](https://github.com/plotly/dash/issues/3276)
- [#3280](https://github.com/plotly/dash/pull/3280) Remove flask typing import not available in earlier versions.
- [#3284](https://github.com/plotly/dash/pull/3284) Fix component as props having the same key when used in the same container.

## [3.0.3] - 2025-04-14

Expand Down
15 changes: 7 additions & 8 deletions dash/dash-renderer/src/wrapper/DashWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ import {
createElement,
getComponentLayout,
isDryComponent,
checkRenderTypeProp
checkRenderTypeProp,
stringifyPath
} from './wrapping';
import Registry from '../registry';
import isSimpleComponent from '../isSimpleComponent';
Expand Down Expand Up @@ -158,17 +159,16 @@ function DashWrapper({
};

const createContainer = useCallback(
(container, containerPath, _childNewRender, key = undefined) => {
(container, containerPath, _childNewRender) => {
if (isSimpleComponent(renderComponent)) {
return renderComponent;
}
return (
<DashWrapper
key={
(container &&
container.props &&
stringifyId(container.props.id)) ||
key
container?.props?.id
? stringifyId(container.props.id)
: stringifyPath(containerPath)
}
_dashprivate_error={_dashprivate_error}
componentPath={containerPath}
Expand All @@ -192,8 +192,7 @@ function DashWrapper({
...childrenPath,
i
]),
_childNewRender,
i
_childNewRender
);
}
return n;
Expand Down