File tree Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change 4
4
TransitionProps as RTGTransitionProps ,
5
5
TransitionStatus ,
6
6
} from 'react-transition-group/Transition' ;
7
+ import { getReactVersion } from './utils' ;
7
8
8
9
export type TransitionProps = RTGTransitionProps & {
9
10
children :
@@ -32,10 +33,14 @@ export default function useRTGTransitionProps({
32
33
children,
33
34
...props
34
35
} : TransitionProps ) {
36
+ const { major } = getReactVersion ( ) ;
37
+ const childRef =
38
+ major >= 19 ? ( children as any ) . props . ref : ( children as any ) . ref ;
39
+
35
40
const nodeRef = useRef < HTMLElement > ( null ) ;
36
41
const mergedRef = useMergedRefs (
37
42
nodeRef ,
38
- typeof children === 'function' ? null : ( children as any ) . ref ,
43
+ typeof children === 'function' ? null : childRef ,
39
44
) ;
40
45
41
46
const normalize =
Original file line number Diff line number Diff line change 1
- /* eslint-disable import/prefer-default-export */
1
+ import * as React from 'react' ;
2
+
2
3
export function isEscKey ( e : KeyboardEvent ) {
3
4
return e . code === 'Escape' || e . keyCode === 27 ;
4
5
}
6
+
7
+ export function getReactVersion ( ) {
8
+ const parts = React . version . split ( '.' ) ;
9
+ return {
10
+ major : + parts [ 0 ] ,
11
+ minor : + parts [ 1 ] ,
12
+ patch : + parts [ 2 ] ,
13
+ } ;
14
+ }
You can’t perform that action at this time.
0 commit comments