From 924899a735b04eaf2a4180faeb86d5f56b95e68a Mon Sep 17 00:00:00 2001 From: Nathan Bierema Date: Tue, 28 Jul 2020 22:26:39 -0400 Subject: [PATCH] docs(react-json-tree): update react-json-tree documentation (#520) * Documentation * Remove newline * Update --- packages/react-json-tree/README.md | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/packages/react-json-tree/README.md b/packages/react-json-tree/README.md index 8e00d47d..03b1f38b 100644 --- a/packages/react-json-tree/README.md +++ b/packages/react-json-tree/README.md @@ -83,8 +83,8 @@ const theme = { textDecoration: 'underline' }, // switch key for objects to uppercase when object is expanded. - // `nestedNodeLabel` receives additional arguments `expanded` and `keyPath` - nestedNodeLabel: ({ style }, nodeType, expanded) => ({ + // `nestedNodeLabel` receives additional argument `expandable` + nestedNodeLabel: ({ style }, keyPath, nodeType, expanded) => ({ style: { ...style, textTransform: expanded ? 'uppercase' : style.textTransform @@ -123,7 +123,7 @@ You can pass the following properties to customize rendered labels and values: ```jsx {raw}} + labelRenderer={([key]) => {key}} valueRenderer={raw => {raw}} /> ``` @@ -132,11 +132,20 @@ In this example the label and value will be rendered with `` and `` For `labelRenderer`, you can provide a full path - [see this PR](https://github.com/chibicode/react-json-tree/pull/32). +Their full signatures are: + +- `labelRenderer: function(keyPath, nodeType, expanded, expandable)` +- `valueRenderer: function(valueAsString, value, ...keyPath)` + #### More Options -- `shouldExpandNode: function(keyName, data, level)` - determines if node should be expanded (root is expanded by default) -- `hideRoot: Boolean` - if `true`, the root node is hidden. -- `sortObjectKeys: Boolean | function(a, b)` - sorts object keys with compare function (optional). Isn't applied to iterable maps like `Immutable.Map`. +- `shouldExpandNode: function(keyPath, data, level)` - determines if node should be expanded (root is expanded by default) +- `hideRoot: boolean` - if `true`, the root node is hidden. +- `sortObjectKeys: boolean | function(a, b)` - sorts object keys with compare function (optional). Isn't applied to iterable maps like `Immutable.Map`. +- `postprocessValue: function(value)` - maps `value` to a new `value` +- `isCustomNode: function(value)` - overrides the default object type detection and renders the value as a single value +- `collectionLimit: number` - sets the number of nodes that will be rendered in a collection before rendering them in collapsed ranges +- `keyPath: (string | number)[]` - overrides the initial key path for the root node (defaults to `[root]`) ### Credits