[react-json-tree] Add keyPath to getItemString args

This commit is contained in:
zorak 2019-03-26 15:14:33 +03:00
parent 03d1448dc3
commit 0075e74ff2
2 changed files with 4 additions and 3 deletions

View File

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

View File

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