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 44 TransitionProps as RTGTransitionProps ,
55 TransitionStatus ,
66} from 'react-transition-group/Transition' ;
7+ import { getReactVersion } from './utils' ;
78
89export type TransitionProps = RTGTransitionProps & {
910 children :
@@ -32,10 +33,14 @@ export default function useRTGTransitionProps({
3233 children,
3334 ...props
3435} : TransitionProps ) {
36+ const { major } = getReactVersion ( ) ;
37+ const childRef =
38+ major >= 19 ? ( children as any ) . props . ref : ( children as any ) . ref ;
39+
3540 const nodeRef = useRef < HTMLElement > ( null ) ;
3641 const mergedRef = useMergedRefs (
3742 nodeRef ,
38- typeof children === 'function' ? null : ( children as any ) . ref ,
43+ typeof children === 'function' ? null : childRef ,
3944 ) ;
4045
4146 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+
23export function isEscKey ( e : KeyboardEvent ) {
34 return e . code === 'Escape' || e . keyCode === 27 ;
45}
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