@@ -49,26 +49,31 @@ export default function TreeNode<T>(props: TreeNodeProps<T>) {
49
49
} = props ;
50
50
let isOpen = false ;
51
51
52
+ const node = React . useRef < HTMLUListElement > ( null ) ;
53
+
52
54
if ( parent && ( parent . key || parent . key === 0 ) ) {
53
55
isOpen = ! ! ( openKeys && openKeys . indexOf ( parent . key ) > - 1 ) ;
54
56
}
55
- const onExit = useCallback ( ( node : HTMLElement ) => {
56
- node . style . height = `${ node . scrollHeight } px` ;
57
+
58
+ const onExit = useCallback ( ( ) => {
59
+ node . current ! . style . height = `${ node . current ! . scrollHeight } px` ;
57
60
} , [ ] ) ;
58
- const onExiting = useCallback ( ( node : HTMLElement ) => {
59
- node . style . height = '1px' ;
61
+ const onExiting = useCallback ( ( ) => {
62
+ node . current ! . style . height = '1px' ;
60
63
} , [ ] ) ;
61
- const onEnter = useCallback ( ( node : HTMLElement , isAppearing : boolean ) => {
62
- node . style . height = '1px' ;
64
+ const onEnter = useCallback ( ( ) => {
65
+ node . current ! . style . height = '1px' ;
63
66
} , [ ] ) ;
64
- const onEntering = useCallback ( ( node : HTMLElement , isAppearing : boolean ) => {
65
- node . style . height = `${ node . scrollHeight } px` ;
67
+ const onEntering = useCallback ( ( ) => {
68
+ node . current ! . style . height = `${ node . current ! . scrollHeight } px` ;
66
69
} , [ ] ) ;
67
- const onEntered = useCallback ( ( node : HTMLElement , isAppearing : boolean ) => {
68
- node . style . height = 'initial' ;
70
+ const onEntered = useCallback ( ( ) => {
71
+ node . current ! . style . height = 'initial' ;
69
72
} , [ ] ) ;
73
+
70
74
return (
71
75
< CSSTransition
76
+ nodeRef = { node }
72
77
classNames = { prefixCls }
73
78
in = { isOpen }
74
79
timeout = { 200 }
@@ -79,6 +84,7 @@ export default function TreeNode<T>(props: TreeNodeProps<T>) {
79
84
onEntering = { onEntering }
80
85
>
81
86
< ul
87
+ ref = { node }
82
88
className = { [
83
89
level !== 1 && isOpen ? [ `${ prefixCls } -open` ] : null ,
84
90
level !== 1 && ! isOpen ? [ `${ prefixCls } -close` ] : null ,
0 commit comments