mirror of
https://github.com/reduxjs/redux-devtools.git
synced 2025-02-23 15:02:52 +03:00
* react-base16-styling * Use inline react-base16-styling themes * Fix * Format * Fix * Fixes * Transform more * react-json-tree * Update lock * Remove unnecessary * react-dock * Move to dep * Lock * Fix * Fix * Create tame-eagles-relax.md
30 lines
876 B
TypeScript
30 lines
876 B
TypeScript
import React from 'react';
|
|
import JSONNestedNode from './JSONNestedNode.js';
|
|
import type { CommonInternalProps } from './types.js';
|
|
|
|
// Returns the "n Items" string for this node,
|
|
// generating and caching it if it hasn't been created yet.
|
|
function createItemString(data: unknown) {
|
|
const len = Object.getOwnPropertyNames(data).length;
|
|
return `${len} ${len !== 1 ? 'keys' : 'key'}`;
|
|
}
|
|
|
|
interface Props extends CommonInternalProps {
|
|
data: unknown;
|
|
nodeType: string;
|
|
}
|
|
|
|
// Configures <JSONNestedNode> to render an Object
|
|
export default function JSONObjectNode({ data, ...props }: Props) {
|
|
return (
|
|
<JSONNestedNode
|
|
{...props}
|
|
data={data}
|
|
nodeType="Object"
|
|
nodeTypeIndicator={props.nodeType === 'Error' ? 'Error()' : '{}'}
|
|
createItemString={createItemString}
|
|
expandable={Object.getOwnPropertyNames(data).length > 0}
|
|
/>
|
|
);
|
|
}
|