@@ -101,12 +101,8 @@ export default function useStatus(
101101 const [ patchMotionEvents ] = useDomMotionEvents ( onInternalMotionEnd ) ;
102102
103103 // ============================= Step =============================
104- const eventHandlers = React . useMemo < {
105- [ STEP_PREPARE ] ?: MotionPrepareEventHandler ;
106- [ STEP_START ] ?: MotionEventHandler ;
107- [ STEP_ACTIVE ] ?: MotionEventHandler ;
108- } > ( ( ) => {
109- switch ( status ) {
104+ const getEventHandlers = ( targetStatus : MotionStatus ) => {
105+ switch ( targetStatus ) {
110106 case STATUS_APPEAR :
111107 return {
112108 [ STEP_PREPARE ] : onAppearPrepare ,
@@ -131,7 +127,13 @@ export default function useStatus(
131127 default :
132128 return { } ;
133129 }
134- } , [ status ] ) ;
130+ } ;
131+
132+ const eventHandlers = React . useMemo < {
133+ [ STEP_PREPARE ] ?: MotionPrepareEventHandler ;
134+ [ STEP_START ] ?: MotionEventHandler ;
135+ [ STEP_ACTIVE ] ?: MotionEventHandler ;
136+ } > ( ( ) => getEventHandlers ( status ) , [ status ] ) ;
135137
136138 const [ startStep , step ] = useStepQueue ( status , ! supportMotion , newStep => {
137139 // Only prepare step can be skip
@@ -205,10 +207,15 @@ export default function useStatus(
205207 nextStatus = STATUS_LEAVE ;
206208 }
207209
210+ const nextEventHandlers = getEventHandlers ( nextStatus ) ;
211+
208212 // Update to next status
209- if ( nextStatus ) {
213+ if ( nextStatus && ( supportMotion || nextEventHandlers [ STEP_PREPARE ] ) ) {
210214 setStatus ( nextStatus ) ;
211215 startStep ( ) ;
216+ } else {
217+ // Set back in case no motion but prev status has prepare step
218+ setStatus ( STATUS_NONE ) ;
212219 }
213220 } , [ visible ] ) ;
214221
0 commit comments