@@ -9,12 +9,9 @@ import type {
99 MotionStatus ,
1010 MotionEventHandler ,
1111 MotionEndEventHandler ,
12- MotionPrepareEventHandler } from './interface' ;
13- import {
14- STATUS_NONE ,
15- STEP_PREPARE ,
16- STEP_START ,
12+ MotionPrepareEventHandler ,
1713} from './interface' ;
14+ import { STATUS_NONE , STEP_PREPARE , STEP_START } from './interface' ;
1815import useStatus from './hooks/useStatus' ;
1916import DomWrapper from './DomWrapper' ;
2017import { isActive } from './hooks/useStepQueue' ;
@@ -135,15 +132,19 @@ export function genCSSMotion(
135132 const supportMotion = isSupportTransition ( props ) ;
136133
137134 // Ref to the react node, it may be a HTMLElement
138- const nodeRef = useRef ( ) ;
135+ const nodeRef = useRef < any > ( ) ;
139136 // Ref to the dom wrapper in case ref can not pass to HTMLElement
140137 const wrapperNodeRef = useRef ( ) ;
141138
142139 function getDomElement ( ) {
143140 try {
144- return findDOMNode < HTMLElement > (
145- nodeRef . current || wrapperNodeRef . current ,
146- ) ;
141+ // Here we're avoiding call for findDOMNode since it's deprecated
142+ // in strict mode. We're calling it only when node ref is not
143+ // an instance of DOM HTMLElement. Otherwise use
144+ // findDOMNode as a final resort
145+ return nodeRef . current instanceof HTMLElement
146+ ? nodeRef . current
147+ : findDOMNode < HTMLElement > ( wrapperNodeRef . current ) ;
147148 } catch ( e ) {
148149 // Only happen when `motionDeadline` trigger but element removed.
149150 return null ;
@@ -157,21 +158,17 @@ export function genCSSMotion(
157158 props ,
158159 ) ;
159160
160- // Record whether content has rended
161+ // Record whether content has rendered
161162 // Will return null for un-rendered even when `removeOnLeave={false}`
162163 const renderedRef = React . useRef ( mergedVisible ) ;
163164 if ( mergedVisible ) {
164165 renderedRef . current = true ;
165166 }
166167
167168 // ====================== Refs ======================
168- const originRef = useRef ( ref ) ;
169- originRef . current = ref ;
170-
171169 const setNodeRef = React . useCallback ( ( node : any ) => {
172170 nodeRef . current = node ;
173-
174- fillRef ( originRef . current , node ) ;
171+ fillRef ( ref , node ) ;
175172 } , [ ] ) ;
176173
177174 // ===================== Render =====================
@@ -213,10 +210,8 @@ export function genCSSMotion(
213210 {
214211 ...mergedProps ,
215212 className : classNames ( getTransitionName ( motionName , status ) , {
216- [ getTransitionName (
217- motionName ,
218- `${ status } -${ statusSuffix } ` ,
219- ) ] : statusSuffix ,
213+ [ getTransitionName ( motionName , `${ status } -${ statusSuffix } ` ) ] :
214+ statusSuffix ,
220215 [ motionName as string ] : typeof motionName === 'string' ,
221216 } ) ,
222217 style : statusStyle ,
0 commit comments