File tree Expand file tree Collapse file tree 3 files changed +23
-3
lines changed Expand file tree Collapse file tree 3 files changed +23
-3
lines changed Original file line number Diff line number Diff line change @@ -51,6 +51,7 @@ class Tree extends React.Component<TreeProps, TreeState> {
51
51
rootNodeClassName : '' ,
52
52
branchNodeClassName : '' ,
53
53
leafNodeClassName : '' ,
54
+ renderCustomNodeElement : undefined ,
54
55
enableLegacyTransitions : false ,
55
56
} ;
56
57
Original file line number Diff line number Diff line change @@ -34,6 +34,16 @@ export interface TreeProps {
34
34
*/
35
35
data : RawNodeDatum [ ] | RawNodeDatum ;
36
36
37
+ /**
38
+ * Custom render function that will be used for every node in the tree.
39
+ *
40
+ * The function is passed `CustomNodeElementProps` as its first argument.
41
+ * `react-d3-tree` expects the function to return a `ReactElement`.
42
+ *
43
+ * See the `RenderCustomNodeElementFn` type for more details.
44
+ *
45
+ * {@link Tree.defaultProps.renderCustomNodeElement | Default value}
46
+ */
37
47
renderCustomNodeElement ?: RenderCustomNodeElementFn ;
38
48
39
49
/**
Original file line number Diff line number Diff line change @@ -33,12 +33,21 @@ export type PathClassFunction = PathFunction;
33
33
34
34
export type SyntheticEventHandler = ( evt : React . SyntheticEvent ) => void ;
35
35
36
+ /**
37
+ * The properties that are passed to the user-defined `renderCustomNodeElement` render function.
38
+ */
36
39
export interface CustomNodeElementProps {
40
+ /**
41
+ * The full datum of the node that is being rendered.
42
+ */
37
43
nodeDatum : TreeNodeDatum ;
44
+ /**
45
+ * Toggles the expanded/collapsed state of the node.
46
+ *
47
+ * Provided for customized control flow; e.g. if we want to toggle the node when its
48
+ * label is clicked instead of the node itself.
49
+ */
38
50
toggleNode : ( ) => void ;
39
51
}
40
52
41
- /**
42
- * Function to render a custom node element. Should return a `ReactElement`.
43
- */
44
53
export type RenderCustomNodeElementFn = ( rd3tProps : CustomNodeElementProps ) => JSX . Element ;
You can’t perform that action at this time.
0 commit comments