@@ -72,7 +72,7 @@ type HookType =
7272
7373// the first instance of a hook mismatch in a component,
7474// represented by a portion of it's stacktrace
75- let currentHookMismatch = null ;
75+ let currentHookMismatchInDev = null ;
7676
7777let didWarnAboutMismatchedHooksForComponent ;
7878if ( __DEV__ ) {
@@ -216,7 +216,7 @@ function flushHookMismatchWarnings() {
216216// and a stack trace so the dev can locate where
217217// the first mismatch is coming from
218218if ( __DEV__ ) {
219- if ( currentHookMismatch !== null ) {
219+ if ( currentHookMismatchInDev !== null ) {
220220let componentName = getComponentName (
221221( ( currentlyRenderingFiber : any ) : Fiber ) . type ,
222222) ;
@@ -280,10 +280,10 @@ function flushHookMismatchWarnings() {
280280hookStackHeader ,
281281hookStackDiff . join ( '\n' ) ,
282282hookStackFooter ,
283- currentHookMismatch ,
283+ currentHookMismatchInDev ,
284284) ;
285285}
286- currentHookMismatch = null ;
286+ currentHookMismatchInDev = null ;
287287}
288288}
289289}
@@ -475,9 +475,9 @@ function cloneHook(hook: Hook): Hook {
475475} ;
476476
477477if ( __DEV__ ) {
478- if ( ! currentHookMismatch ) {
478+ if ( currentHookMismatchInDev === null ) {
479479if ( currentHookNameInDev !== ( ( hook : any ) : HookDev ) . _debugType ) {
480- currentHookMismatch = new Error ( 'tracer' ) . stack
480+ currentHookMismatchInDev = new Error ( 'tracer' ) . stack
481481. split ( '\n' )
482482. slice ( 4 )
483483. join ( '\n' ) ;
@@ -582,7 +582,9 @@ export function useReducer<S, A>(
582582}
583583let fiber = ( currentlyRenderingFiber = resolveCurrentlyRenderingFiber ( ) ) ;
584584workInProgressHook = createWorkInProgressHook ( ) ;
585- currentHookNameInDev = null ;
585+ if ( __DEV__ ) {
586+ currentHookNameInDev = null ;
587+ }
586588 let queue: UpdateQueue< S , A > | null = (workInProgressHook.queue: any);
587589 if (queue !== null) {
588590// Already have a queue, so this is an update.
@@ -771,7 +773,9 @@ export function useRef<T>(initialValue: T): {current: T} {
771773currentHookNameInDev = 'useRef' ;
772774}
773775 workInProgressHook = createWorkInProgressHook();
774- currentHookNameInDev = null;
776+ if (__DEV__) {
777+ currentHookNameInDev = null ;
778+ }
775779 let ref;
776780
777781 if (workInProgressHook.memoizedState === null) {
@@ -826,7 +830,9 @@ function useEffectImpl(fiberEffectTag, hookEffectTag, create, deps): void {
826830const prevDeps = prevEffect . deps ;
827831if ( areHookInputsEqual ( nextDeps , prevDeps ) ) {
828832pushEffect ( NoHookEffect , create , destroy , nextDeps ) ;
829- currentHookNameInDev = null ;
833+ if ( __DEV__ ) {
834+ currentHookNameInDev = null ;
835+ }
830836return ;
831837}
832838}
@@ -839,7 +845,9 @@ function useEffectImpl(fiberEffectTag, hookEffectTag, create, deps): void {
839845destroy ,
840846nextDeps ,
841847) ;
842- currentHookNameInDev = null ;
848+ if ( __DEV__ ) {
849+ currentHookNameInDev = null ;
850+ }
843851}
844852
845853export function useImperativeHandle < T > (
@@ -927,7 +935,9 @@ export function useCallback<T>(
927935}
928936}
929937 workInProgressHook.memoizedState = [callback, nextDeps];
930- currentHookNameInDev = null;
938+ if (__DEV__) {
939+ currentHookNameInDev = null ;
940+ }
931941 return callback;
932942}
933943
@@ -949,7 +959,9 @@ export function useMemo<T>(
949959if ( nextDeps !== null ) {
950960const prevDeps : Array < mixed > | null = prevState [ 1 ] ;
951961if ( areHookInputsEqual ( nextDeps , prevDeps ) ) {
952- currentHookNameInDev = null ;
962+ if ( __DEV__ ) {
963+ currentHookNameInDev = null ;
964+ }
953965return prevState [ 0 ] ;
954966}
955967}
@@ -962,7 +974,9 @@ export function useMemo<T>(
962974currentlyRenderingFiber = fiber ;
963975unstashContextDependencies ( ) ;
964976workInProgressHook . memoizedState = [ nextValue , nextDeps ] ;
965- currentHookNameInDev = null;
977+ if ( __DEV__ ) {
978+ currentHookNameInDev = null ;
979+ }
966980 return nextValue;
967981}
968982
0 commit comments