@@ -174,7 +174,7 @@ type Dispatch<A> = A => void;
174
174
let renderExpirationTime : ExpirationTime = NoWork ;
175
175
// The work-in-progress fiber. I've named it differently to distinguish it from
176
176
// the work-in-progress hook.
177
- let currentlyRenderingFiber : Fiber | null = null ;
177
+ let currentlyRenderingFiber : Fiber = ( null : any ) ;
178
178
179
179
// Hooks are stored as a linked list on the fiber's memoizedState field. The
180
180
// current hook list is the list that belongs to the current fiber. The
@@ -259,7 +259,7 @@ function checkDepsAreArrayDev(deps: mixed) {
259
259
function warnOnHookMismatchInDev ( currentHookName : HookType ) {
260
260
if ( __DEV__ ) {
261
261
const componentName = getComponentName (
262
- ( ( currentlyRenderingFiber : any ) : Fiber ) . type ,
262
+ currentlyRenderingFiber . type ,
263
263
) ;
264
264
if ( ! didWarnAboutMismatchedHooksForComponent . has ( componentName ) ) {
265
265
didWarnAboutMismatchedHooksForComponent . add ( componentName ) ;
@@ -483,7 +483,7 @@ export function renderWithHooks(
483
483
currentHook !== null && currentHook.next !== null;
484
484
485
485
renderExpirationTime = NoWork;
486
- currentlyRenderingFiber = null;
486
+ currentlyRenderingFiber = ( null: any) ;
487
487
488
488
currentHook = null;
489
489
workInProgressHook = null;
@@ -529,7 +529,7 @@ export function resetHooks(): void {
529
529
// component is a module-style component.
530
530
531
531
renderExpirationTime = NoWork;
532
- currentlyRenderingFiber = null;
532
+ currentlyRenderingFiber = ( null: any) ;
533
533
534
534
currentHook = null;
535
535
workInProgressHook = null;
@@ -558,8 +558,7 @@ function mountWorkInProgressHook(): Hook {
558
558
559
559
if (workInProgressHook === null) {
560
560
// This is the first hook in the list
561
- let fiber = ((currentlyRenderingFiber: any): Fiber);
562
- fiber.memoizedState = workInProgressHook = hook;
561
+ currentlyRenderingFiber.memoizedState = workInProgressHook = hook;
563
562
} else {
564
563
// Append to the end of the list
565
564
workInProgressHook = workInProgressHook.next = hook;
@@ -575,8 +574,7 @@ function updateWorkInProgressHook(): Hook {
575
574
// the dispatcher used for mounts.
576
575
let nextCurrentHook: null | Hook;
577
576
if (currentHook === null) {
578
- let fiber = ((currentlyRenderingFiber: any): Fiber);
579
- let current = fiber.alternate;
577
+ let current = currentlyRenderingFiber.alternate;
580
578
if (current !== null) {
581
579
nextCurrentHook = current.memoizedState;
582
580
} else {
@@ -588,8 +586,7 @@ function updateWorkInProgressHook(): Hook {
588
586
589
587
let nextWorkInProgressHook: null | Hook;
590
588
if (workInProgressHook === null) {
591
- let fiber = ((currentlyRenderingFiber: any): Fiber);
592
- nextWorkInProgressHook = fiber.memoizedState;
589
+ nextWorkInProgressHook = currentlyRenderingFiber.memoizedState;
593
590
} else {
594
591
nextWorkInProgressHook = workInProgressHook.next;
595
592
}
@@ -621,8 +618,7 @@ function updateWorkInProgressHook(): Hook {
621
618
622
619
if (workInProgressHook === null) {
623
620
// This is the first hook in the list.
624
- let fiber = ((currentlyRenderingFiber: any): Fiber);
625
- fiber.memoizedState = workInProgressHook = newHook;
621
+ currentlyRenderingFiber.memoizedState = workInProgressHook = newHook;
626
622
} else {
627
623
// Append to the end of the list.
628
624
workInProgressHook = workInProgressHook.next = newHook;
@@ -662,8 +658,7 @@ function mountReducer<S, I, A>(
662
658
});
663
659
const dispatch: Dispatch<A> = (queue.dispatch = (dispatchAction.bind(
664
660
null,
665
- // Flow doesn't know this is non-null, but we do.
666
- ((currentlyRenderingFiber: any): Fiber),
661
+ currentlyRenderingFiber,
667
662
queue,
668
663
): any));
669
664
return [hook.memoizedState, dispatch];
@@ -762,9 +757,8 @@ function updateReducer<S, I, A>(
762
757
newBaseState = newState ;
763
758
}
764
759
// Update the remaining priority in the queue.
765
- let fiber = ( ( currentlyRenderingFiber : any ) : Fiber ) ;
766
- if ( updateExpirationTime > fiber . expirationTime ) {
767
- fiber . expirationTime = updateExpirationTime ;
760
+ if ( updateExpirationTime > currentlyRenderingFiber . expirationTime ) {
761
+ currentlyRenderingFiber . expirationTime = updateExpirationTime ;
768
762
markUnprocessedUpdateTime ( updateExpirationTime ) ;
769
763
}
770
764
} else {
@@ -835,8 +829,7 @@ function mountState<S>(
835
829
BasicStateAction < S > ,
836
830
> = ( queue . dispatch = ( dispatchAction . bind (
837
831
null ,
838
- // Flow doesn't know this is non-null, but we do.
839
- ( ( currentlyRenderingFiber : any ) : Fiber ) ,
832
+ currentlyRenderingFiber ,
840
833
queue ,
841
834
) : any ) ) ;
842
835
return [ hook . memoizedState , dispatch ] ;
@@ -857,10 +850,10 @@ function pushEffect(tag, create, destroy, deps) {
857
850
// Circular
858
851
next : ( null : any ) ,
859
852
} ;
860
- let fiber = ( ( currentlyRenderingFiber : any ) : Fiber ) ;
861
- let componentUpdateQueue : null | FunctionComponentUpdateQueue = ( fiber . updateQueue : any ) ;
853
+ let componentUpdateQueue : null | FunctionComponentUpdateQueue = ( currentlyRenderingFiber . updateQueue : any ) ;
862
854
if ( componentUpdateQueue === null ) {
863
- ( fiber : any ) . updateQueue = componentUpdateQueue = createFunctionComponentUpdateQueue ( ) ;
855
+ componentUpdateQueue = createFunctionComponentUpdateQueue ( ) ;
856
+ currentlyRenderingFiber . updateQueue = ( componentUpdateQueue : any ) ;
864
857
componentUpdateQueue . lastEffect = effect . next = effect ;
865
858
} else {
866
859
const lastEffect = componentUpdateQueue . lastEffect ;
@@ -894,8 +887,7 @@ function updateRef<T>(initialValue: T): {current: T} {
894
887
function mountEffectImpl ( fiberEffectTag , hookEffectTag , create , deps ) : void {
895
888
const hook = mountWorkInProgressHook ( ) ;
896
889
const nextDeps = deps === undefined ? null : deps ;
897
- let fiber = ( ( currentlyRenderingFiber : any ) : Fiber ) ;
898
- fiber . effectTag |= fiberEffectTag ;
890
+ currentlyRenderingFiber . effectTag |= fiberEffectTag ;
899
891
hook . memoizedState = pushEffect ( hookEffectTag , create , undefined , nextDeps ) ;
900
892
}
901
893
@@ -916,8 +908,7 @@ function updateEffectImpl(fiberEffectTag, hookEffectTag, create, deps): void {
916
908
}
917
909
}
918
910
919
- let fiber = ( ( currentlyRenderingFiber : any ) : Fiber ) ;
920
- fiber . effectTag |= fiberEffectTag ;
911
+ currentlyRenderingFiber . effectTag |= fiberEffectTag ;
921
912
922
913
hook . memoizedState = pushEffect ( hookEffectTag , create , destroy , nextDeps ) ;
923
914
}
@@ -930,7 +921,7 @@ function mountEffect(
930
921
// $FlowExpectedError - jest isn't a global, and isn't recognized outside of tests
931
922
if ( 'undefined ' !== typeof jest ) {
932
923
warnIfNotCurrentlyActingEffectsInDEV (
933
- ( ( currentlyRenderingFiber : any ) : Fiber ) ,
924
+ currentlyRenderingFiber ,
934
925
) ;
935
926
}
936
927
}
@@ -950,7 +941,7 @@ function updateEffect(
950
941
// $FlowExpectedError - jest isn't a global, and isn't recognized outside of tests
951
942
if ( 'undefined ' !== typeof jest ) {
952
943
warnIfNotCurrentlyActingEffectsInDEV (
953
- ( ( currentlyRenderingFiber : any ) : Fiber ) ,
944
+ currentlyRenderingFiber ,
954
945
) ;
955
946
}
956
947
}
0 commit comments