File tree Expand file tree Collapse file tree 2 files changed +3
-3
lines changed
packages/@react-stately/data Expand file tree Collapse file tree 2 files changed +3
-3
lines changed Original file line number Diff line number Diff line change @@ -123,7 +123,7 @@ export function useTreeData<T extends object>(options: TreeOptions<T>): TreeData
123
123
initialItems = [ ] ,
124
124
initialSelectedKeys,
125
125
getKey = ( item : any ) => item . id || item . key ,
126
- getChildren = ( item : any ) => item . children || [ ]
126
+ getChildren = ( item : any ) => item . children
127
127
} = options ;
128
128
let map = useMemo ( ( ) => new Map < Key , TreeNode < T > > ( ) , [ ] ) ;
129
129
@@ -133,7 +133,7 @@ export function useTreeData<T extends object>(options: TreeOptions<T>): TreeData
133
133
let [ items , setItems ] = useState ( initialNodes ) ;
134
134
let [ selectedKeys , setSelectedKeys ] = useState ( new Set < Key > ( initialSelectedKeys || [ ] ) ) ;
135
135
136
- function buildTree ( initialItems : T [ ] , parentKey ?: Key | null ) {
136
+ function buildTree ( initialItems : T [ ] = [ ] , parentKey ?: Key | null ) {
137
137
return initialItems . map ( item => {
138
138
let node : TreeNode < T > = {
139
139
key : getKey ( item ) ,
Original file line number Diff line number Diff line change @@ -31,7 +31,7 @@ const initial = [
31
31
] ;
32
32
33
33
let getKey = ( item ) => item . name ;
34
- let getChildren = ( item ) => item . children || [ ] ;
34
+ let getChildren = ( item ) => item . children ;
35
35
36
36
describe ( 'useTreeData' , function ( ) {
37
37
it ( 'should construct a tree using initial data' , function ( ) {
You can’t perform that action at this time.
0 commit comments