feat(react-json-tree): Add keyPath to getItemString

This commit is contained in:
joshhunt 2020-12-22 13:48:38 +00:00
parent a46b43209d
commit 6449dc1fa4
3 changed files with 6 additions and 4 deletions

View File

@ -102,14 +102,14 @@ You can pass `getItemString` to customize the way arrays, objects, and iterable
By default, it'll be:
```jsx
<JSONTree getItemString={(type, data, itemType, itemString)
<JSONTree getItemString={(type, data, itemType, itemString, keyPath)
=> <span>{itemType} {itemString}</span>}
```
But if you pass the following:
```jsx
const getItemString = (type, data, itemType, itemString)
const getItemString = (type, data, itemType, itemString, keyPath)
=> (<span> // {type}</span>);
```

View File

@ -193,7 +193,8 @@ export default class JSONNestedNode extends React.Component<Props, State> {
nodeType,
data,
itemType,
createItemString(data, collectionLimit)
createItemString(data, collectionLimit),
keyPath
);
const stylingArgs = [keyPath, nodeType, expanded, expandable] as const;

View File

@ -35,7 +35,8 @@ interface JSONNestedNodeCircularPropsPassedThroughJSONTree {
nodeType: string,
data: any,
itemType: React.ReactNode,
itemString: string
itemString: string,
keyPath: (string | number)[]
) => React.ReactNode;
postprocessValue: (value: any) => any;
isCustomNode: (value: any) => boolean;