@@ -622,35 +622,24 @@ export function useHeTree<T extends Record<string, any>>(
622
622
const { visibleIds, attrsList, onDragOverRoot, onDropToRoot, onDragEndOnRoot } = cacheForVisible
623
623
const persistentIndices = useMemo ( ( ) => draggedStat ? [ visibleIds . indexOf ( draggedStat . id ) ] : [ ] , [ draggedStat , visibleIds ] ) ;
624
624
// render
625
- const renderHeTree = useMemo (
626
- ( ) => {
627
- let cached : ReactNode
628
- return ( ) => {
629
- if ( ! cached ) {
630
- let renderNodeBox = props . renderNodeBox !
631
- if ( ! renderNodeBox ) {
632
- const placeholder = < div className = "he-tree-drag-placeholder" style = { { minHeight : '20px' , border : '1px dashed blue' } } > </ div >
633
- renderNodeBox = ( { stat, attrs, isPlaceholder } ) => < div { ...attrs } >
634
- { isPlaceholder ? placeholder : props . renderNode ! ( stat ) }
635
- </ div >
636
- }
637
- //
638
- cached = (
639
- < div className = { `he-tree` } ref = { rootRef } onDragOver = { onDragOverRoot } onDrop = { onDropToRoot } onDragEnd = { onDragEndOnRoot } >
640
- < VirtualList < Id > ref = { virtualListRef } items = { visibleIds } virtual = { false } persistentIndices = { persistentIndices }
641
- renderItem = { ( id , index ) => renderNodeBox ( {
642
- stat : getStat ( id ) ! , attrs : attrsList [ index ] , isPlaceholder : id === placeholderId
643
- } ) }
644
- />
645
- </ div >
646
- )
647
- }
648
- return cached
649
- }
650
- } , [ cacheForVisible . visibleIds ,
651
- isFunctionReactive && props . renderNode ,
652
- isFunctionReactive && props . renderNodeBox ,
653
- ] ) ;
625
+ const renderHeTree = ( options ?: { className ?: string , style ?: React . CSSProperties } ) => {
626
+ let renderNodeBox = props . renderNodeBox !
627
+ if ( ! renderNodeBox ) {
628
+ const placeholder = < div className = "he-tree-drag-placeholder" style = { { minHeight : '20px' , border : '1px dashed blue' } } > </ div >
629
+ renderNodeBox = ( { stat, attrs, isPlaceholder } ) => < div { ...attrs } >
630
+ { isPlaceholder ? placeholder : props . renderNode ! ( stat ) }
631
+ </ div >
632
+ }
633
+ return (
634
+ < div className = { `he-tree ${ options ?. className || '' } ` } style = { options ?. style } ref = { rootRef } onDragOver = { onDragOverRoot } onDrop = { onDropToRoot } onDragEnd = { onDragEndOnRoot } >
635
+ < VirtualList < Id > ref = { virtualListRef } items = { visibleIds } virtual = { false } persistentIndices = { persistentIndices }
636
+ renderItem = { ( id , index ) => renderNodeBox ( {
637
+ stat : getStat ( id ) ! , attrs : attrsList [ index ] , isPlaceholder : id === placeholderId
638
+ } ) }
639
+ />
640
+ </ div >
641
+ )
642
+ }
654
643
655
644
return {
656
645
...mainCache ,
0 commit comments