You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-`FixedSizeNodePublicState<TData extends FixedSizeNodeData>` - the node state available for the `Node` component and `recomputeTree`'s `subtreeCallback` function. It has the following shape:
298
298
-`data: FixedSizeNodeData`.
299
299
-`isOpen: boolean` - a current openness status of the node.
300
-
-`toggle: function` - a function to change the openness state of the node. It receives no arguments and can be provided directly as an `onClick` handler.
300
+
-`setOpen(state: boolean): function` - a function to change the openness state of the node. It receives the new openness state as a `boolean` and opens/closes the node accordingly.
301
301
-`FixedSizeTreeProps<TData extends FixedSizeNodeData>` - props that `FixedSizeTree` component receives. Described in the [Props](#props) section.
302
302
-`FixedSizeTreeState<TData extends FixedSizeNodeData>` - state that `FixedSizeTree` component has.
303
303
@@ -373,10 +373,10 @@ function* treeWalker() {
373
373
}
374
374
375
375
// Node component receives current node height as a prop
@@ -493,8 +493,7 @@ The `treeWalker` was and is the heart of the `react-vtree`. However, now it look
493
493
Old `treeWalker` worked for both initial tree building and changing node openness state:
494
494
495
495
```js
496
-
function*treeWalker( refresh
497
-
) {
496
+
function*treeWalker(refresh) {
498
497
conststack= [];
499
498
500
499
stack.push({
@@ -586,6 +585,7 @@ The `recomputeTree` method now receives a list of nodes to change (previously, i
586
585
The most important change is the introduction of the `subtreeCallback`. It is a function that will be applied to each node in the subtree of the specified node. Among other useful things it also allows imitating the behavior of old `useDefaultOpenness` and `useDefaultHeight` options.
587
586
588
587
Old `recomputeTree`:
588
+
589
589
```js
590
590
treeInstance.recomputeTree({
591
591
opennessState: {
@@ -594,7 +594,7 @@ treeInstance.recomputeTree({
594
594
'node-3':false,
595
595
},
596
596
refreshNodes:true,
597
-
useDefaultOpenness:false
597
+
useDefaultOpenness:false,
598
598
});
599
599
```
600
600
@@ -609,8 +609,42 @@ treeInstance.recomputeTree({
609
609
if (node !== ownerNode) {
610
610
node.isOpen=false;
611
611
}
612
-
}
612
+
},
613
613
},
614
614
'node-3':false,
615
615
});
616
+
```
617
+
618
+
### 4. Migrate all your `toggle()` calls to `setOpen(boolean)`
619
+
620
+
In the `3.x.x` version node provides a `setOpen` function instead of `toggle` that allows more fine-grained control over the openness state.
0 commit comments