diff --git a/docs/src/pages/customization/default-theme/DefaultTheme.js b/docs/src/pages/customization/default-theme/DefaultTheme.js index d9fea8b3c23f53..00081240189ab5 100644 --- a/docs/src/pages/customization/default-theme/DefaultTheme.js +++ b/docs/src/pages/customization/default-theme/DefaultTheme.js @@ -91,15 +91,10 @@ function TreeLabel({ objectKey, objectValue }) { } TreeLabel.propTypes = { objectKey: PropTypes.any, objectValue: PropTypes.any }; -/** - * @type {React.Context} - */ -const ObjectContext = React.createContext('$ROOT'); - function ObjectTreeItem(props) { - const { nodeId, objectValue } = props; + const { nodeId, objectKey, objectValue } = props; - const keyPrefix = React.useContext(ObjectContext); + const keyPrefix = nodeId; if ( (objectValue !== null && typeof objectValue === 'object') || @@ -109,34 +104,43 @@ function ObjectTreeItem(props) { Object.keys(objectValue).length === 0 ? undefined : Object.keys(objectValue).map(key => { - return ; + return ( + + ); }); // false hierarchy but items must be immediate children with a `nodeId` prop return ( - - } - > - {children} - - + } + > + {children} + ); } return ( } + nodeId={nodeId} + label={} /> ); } -ObjectTreeItem.propTypes = { nodeId: PropTypes.any, objectValue: PropTypes.any }; +ObjectTreeItem.propTypes = { + nodeId: PropTypes.string.isRequired, + objectKey: PropTypes.any.isRequired, + objectValue: PropTypes.any, +}; function Inspector(props) { const { data, expandPaths } = props; - const keyPrefix = React.useContext(ObjectContext); + const keyPrefix = '$ROOT'; const defaultExpanded = React.useMemo(() => { return Array.isArray(expandPaths) ? expandPaths.map(expandPath => `${keyPrefix}.${expandPath}`) @@ -153,7 +157,14 @@ function Inspector(props) { defaultExpandIcon={} > {Object.keys(data).map(key => { - return ; + return ( + + ); })} );