redux-devtools/packages/react-json-tree/src/JSONValueNode.tsx
Nathan Bierema 81926f3212
Remove UNSAFE methods from react-json-tree (#1288)
* 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
2023-01-04 23:17:44 -05:00

47 lines
979 B
TypeScript

import React from 'react';
import type {
GetItemString,
Key,
KeyPath,
LabelRenderer,
Styling,
ValueRenderer,
} from './types';
/**
* Renders simple values (eg. strings, numbers, booleans, etc)
*/
interface Props {
getItemString: GetItemString;
key: Key;
keyPath: KeyPath;
labelRenderer: LabelRenderer;
nodeType: string;
styling: Styling;
value: unknown;
valueRenderer: ValueRenderer;
valueGetter?: (value: any) => unknown;
}
export default function JSONValueNode({
nodeType,
styling,
labelRenderer,
keyPath,
valueRenderer,
value,
valueGetter = (value) => value,
}: Props) {
return (
<li {...styling('value', nodeType, keyPath)}>
<label {...styling(['label', 'valueLabel'], nodeType, keyPath)}>
{labelRenderer(keyPath, nodeType, false, false)}
</label>
<span {...styling('valueText', nodeType, keyPath)}>
{valueRenderer(valueGetter(value), value, ...keyPath)}
</span>
</li>
);
}