Skip to content

Commit 3e8e10e

Browse files
committed
Add section to README about the tree data utils
1 parent 495a08d commit 3e8e10e

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,24 @@ slideRegionSize | number | `100` | | Si
6161
scaffoldBlockPxWidth | number | `44` | | The width of the blocks containing the lines representing the structure of the tree.
6262
nodeContentRenderer | any | NodeRendererDefault | | Override the default component for rendering nodes (but keep the scaffolding generator) This is an advanced option for complete customization of the appearance. It is best to copy the component in `node-renderer-default.js` to use as a base, and customize as needed.
6363

64+
## Data Helper Functions
65+
66+
Need a hand turning your flat data into nested tree data?
67+
Want to perform add/remove operations on the tree data without creating your own recursive function?
68+
Check out the helper functions exported from [`tree-data-utils.js`](https://github.com/fritz-c/react-sortable-tree/blob/master/src/utils/tree-data-utils.js).
69+
70+
Notable among the available functions:
71+
72+
- __`getTreeFromFlatData`__: Convert flat data (like that from a database) into nested tree data
73+
- __`getFlatDataFromTree`__: Convert tree data back to flat data
74+
- __`addNodeUnderParent`__: Add a node under the parent node at the given path
75+
- __`removeNodeAtPath`__: Remove the node at the given path
76+
- __`map`__: Perform a change on every node in the tree
77+
- __`walk`__: Visit every node in the tree in order
78+
79+
Documentation for each method is only available in the code at this time.
80+
If your hobbies happen to include writing documentation, by all means submit a pull request. It would really help out.
81+
6482
## Browser Compatibility
6583

6684
| Browser | Works? |

0 commit comments

Comments
 (0)