ReactObjectTableViewer can handle components

This commit is contained in:
Simon Li
2023-04-14 23:29:53 +01:00
parent 8c10fb285e
commit b3f9635ecc

View File

@@ -20,6 +20,7 @@ const ReactObjectTableViewer = (props) => {
{keys.map((k, key) => {
const val = data[k];
const isObject = typeof val === "object";
const isElement = React.isValidElement(val);
return (
<tr key={key}>
@@ -32,7 +33,8 @@ const ReactObjectTableViewer = (props) => {
</th>
{isObject && (
<td>
<ReactObjectTableViewer {...opt} data={val} />
{isElement && val}
{!isElement && <ReactObjectTableViewer {...opt} data={val} />}
</td>
)}
{!isObject && (
@@ -53,9 +55,9 @@ const ReactObjectTableViewer = (props) => {
ReactObjectTableViewer.propTypes = {
data: PropTypes.object,
style: PropTypes.CSSProperties,
keyStyle: PropTypes.CSSProperties,
valueStyle: PropTypes.CSSProperties,
style: PropTypes.objectOf(PropTypes.string),
keyStyle: PropTypes.objectOf(PropTypes.string),
valueStyle: PropTypes.objectOf(PropTypes.string),
className: PropTypes.string,
layout: PropTypes.string,
};