@@ -407,7 +407,9 @@ export function renderWithHooks<Props, SecondArg>(
407
407
// be null during updates and mounts.
408
408
if (
409
409
current !== null &&
410
- ( enableThrowOnMountForHookMismatch || current . memoizedState !== null )
410
+ ( ( enableThrowOnMountForHookMismatch &&
411
+ ( current . mode & ConcurrentMode ) !== NoMode ) ||
412
+ current . memoizedState !== null )
411
413
) {
412
414
ReactCurrentDispatcher . current = HooksDispatcherOnUpdateInDEV ;
413
415
} else if ( current !== null ) {
@@ -422,9 +424,12 @@ export function renderWithHooks<Props, SecondArg>(
422
424
}
423
425
} else {
424
426
ReactCurrentDispatcher . current =
425
- current === null || current . memoizedState === null
426
- ? HooksDispatcherOnMount
427
- : HooksDispatcherOnUpdate ;
427
+ current !== null &&
428
+ ( ( enableThrowOnMountForHookMismatch &&
429
+ ( current . mode & ConcurrentMode ) !== NoMode ) ||
430
+ current . memoizedState !== null )
431
+ ? HooksDispatcherOnUpdate
432
+ : HooksDispatcherOnMount ;
428
433
}
429
434
430
435
let children = Component ( props , secondArg ) ;
@@ -484,8 +489,9 @@ export function renderWithHooks<Props, SecondArg>(
484
489
const didRenderTooFewHooks =
485
490
( currentHook !== null && currentHook . next !== null ) ||
486
491
( enableThrowOnMountForHookMismatch &&
487
- current !== null &&
488
- current . memoizedState !== null &&
492
+ current != null &&
493
+ ( current . mode & ConcurrentMode ) !== NoMode &&
494
+ current . memoizedState != null &&
489
495
workInProgress . memoizedState == null ) ;
490
496
491
497
renderLanes = NoLanes ;
0 commit comments