Skip to content

Add key to wrapped children props in list. #2332

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 7 commits into from
Dec 5, 2022
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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
All notable changes to `dash` will be documented in this file.
This project adheres to [Semantic Versioning](https://semver.org/).

## [UNRELEASED]

### Fixed

- [#2332](https://github.com/plotly/dash/pull/2332) Add key to wrapped children props in list.

## [2.7.0] - 2022-11-03

### Removed
Expand Down
37 changes: 20 additions & 17 deletions dash/dash-renderer/src/TreeContainer.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, {Component, memo} from 'react';
import React, {Component, memo, useContext} from 'react';
import PropTypes from 'prop-types';
import Registry from './registry';
import {propTypeErrorHandler} from './exceptions';
Expand Down Expand Up @@ -81,17 +81,18 @@ function isDryComponent(obj) {
);
}

const TreeContainer = memo(props => (
<DashContext.Consumer>
{context => (
<BaseTreeContainer
{...context.fn()}
{...props}
_dashprivate_path={JSON.parse(props._dashprivate_path)}
/>
)}
</DashContext.Consumer>
));
const DashWrapper = props => {
const context = useContext(DashContext);
return (
<BaseTreeContainer
{...context.fn()}
{...props}
_dashprivate_path={JSON.parse(props._dashprivate_path)}
/>
);
};

const TreeContainer = memo(DashWrapper);

class BaseTreeContainer extends Component {
constructor(props) {
Expand All @@ -100,15 +101,16 @@ class BaseTreeContainer extends Component {
this.setProps = this.setProps.bind(this);
}

createContainer(props, component, path) {
createContainer(props, component, path, key = undefined) {
return isSimpleComponent(component) ? (
component
) : (
<TreeContainer
key={
component &&
component.props &&
stringifyId(component.props.id)
(component &&
component.props &&
stringifyId(component.props.id)) ||
key
}
_dashprivate_error={props._dashprivate_error}
_dashprivate_layout={component}
Expand Down Expand Up @@ -205,7 +207,8 @@ class BaseTreeContainer extends Component {
'props',
...childrenProp,
i
])
]),
i
)
: n
);
Expand Down