Skip to content

Commit 924899a

Browse files
authored
docs(react-json-tree): update react-json-tree documentation (#520)
* Documentation * Remove newline * Update
1 parent 632f744 commit 924899a

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

packages/react-json-tree/README.md

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ const theme = {
8383
textDecoration: 'underline'
8484
},
8585
// switch key for objects to uppercase when object is expanded.
86-
// `nestedNodeLabel` receives additional arguments `expanded` and `keyPath`
87-
nestedNodeLabel: ({ style }, nodeType, expanded) => ({
86+
// `nestedNodeLabel` receives additional argument `expandable`
87+
nestedNodeLabel: ({ style }, keyPath, nodeType, expanded) => ({
8888
style: {
8989
...style,
9090
textTransform: expanded ? 'uppercase' : style.textTransform
@@ -123,7 +123,7 @@ You can pass the following properties to customize rendered labels and values:
123123
124124
```jsx
125125
<JSONTree
126-
labelRenderer={raw => <strong>{raw}</strong>}
126+
labelRenderer={([key]) => <strong>{key}</strong>}
127127
valueRenderer={raw => <em>{raw}</em>}
128128
/>
129129
```
@@ -132,11 +132,20 @@ In this example the label and value will be rendered with `<strong>` and `<em>`
132132
133133
For `labelRenderer`, you can provide a full path - [see this PR](https://github.com/chibicode/react-json-tree/pull/32).
134134
135+
Their full signatures are:
136+
137+
- `labelRenderer: function(keyPath, nodeType, expanded, expandable)`
138+
- `valueRenderer: function(valueAsString, value, ...keyPath)`
139+
135140
#### More Options
136141

137-
- `shouldExpandNode: function(keyName, data, level)` - determines if node should be expanded (root is expanded by default)
138-
- `hideRoot: Boolean` - if `true`, the root node is hidden.
139-
- `sortObjectKeys: Boolean | function(a, b)` - sorts object keys with compare function (optional). Isn't applied to iterable maps like `Immutable.Map`.
142+
- `shouldExpandNode: function(keyPath, data, level)` - determines if node should be expanded (root is expanded by default)
143+
- `hideRoot: boolean` - if `true`, the root node is hidden.
144+
- `sortObjectKeys: boolean | function(a, b)` - sorts object keys with compare function (optional). Isn't applied to iterable maps like `Immutable.Map`.
145+
- `postprocessValue: function(value)` - maps `value` to a new `value`
146+
- `isCustomNode: function(value)` - overrides the default object type detection and renders the value as a single value
147+
- `collectionLimit: number` - sets the number of nodes that will be rendered in a collection before rendering them in collapsed ranges
148+
- `keyPath: (string | number)[]` - overrides the initial key path for the root node (defaults to `[root]`)
140149

141150
### Credits
142151

0 commit comments

Comments
 (0)