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