mirror of
https://github.com/reduxjs/redux-devtools.git
synced 2025-04-27 11:43:42 +03:00
* Remove UNSAFE method from JSONTree * Bump peer dep * Fix types * Remove proptypes * Remove unused * shouldExpandNode => shouldExpandNodeInitially * Cleanup * Update usages * Tighten types * Create four-parrots-poke.md * Format * Fix inspector-monitor types * Fix log-monitor types * Fix rtk-query-monitor types * Fix type
31 lines
812 B
TypeScript
31 lines
812 B
TypeScript
import React from 'react';
|
|
import JSONNestedNode from './JSONNestedNode';
|
|
import type { CommonInternalProps } from './types';
|
|
|
|
// Returns the "n Items" string for this node,
|
|
// generating and caching it if it hasn't been created yet.
|
|
function createItemString(data: unknown) {
|
|
return `${(data as unknown[]).length} ${
|
|
(data as unknown[]).length !== 1 ? 'items' : 'item'
|
|
}`;
|
|
}
|
|
|
|
interface Props extends CommonInternalProps {
|
|
data: unknown;
|
|
nodeType: string;
|
|
}
|
|
|
|
// Configures <JSONNestedNode> to render an Array
|
|
export default function JSONArrayNode({ data, ...props }: Props) {
|
|
return (
|
|
<JSONNestedNode
|
|
{...props}
|
|
data={data}
|
|
nodeType="Array"
|
|
nodeTypeIndicator="[]"
|
|
createItemString={createItemString}
|
|
expandable={(data as unknown[]).length > 0}
|
|
/>
|
|
);
|
|
}
|