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