10
import type {Fiber} from './ReactFiber';
11
import type {ExpirationTime} from './ReactFiberExpirationTime';
12
import type {LegacyContext} from './ReactFiberContext';
13
-import type {CapturedValue} from './ReactCapturedValue';
13
14
import {Update, Snapshot} from 'shared/ReactTypeOfSideEffect';
15
import {
17
- enableGetDerivedStateFromCatch,
16
debugRenderPhaseSideEffects,
17
debugRenderPhaseSideEffectsForStrictMode,
18
warnAboutDeprecatedLifecycles,
29
import {startPhaseTimer, stopPhaseTimer} from './ReactDebugFiberPerf';
30
import {StrictMode} from './ReactTypeOfMode';
31
import {
34
- insertUpdateIntoFiber,
32
+ enqueueUpdate,
33
processUpdateQueue,
36
-} from './ReactFiberUpdateQueue';
34
+ createUpdate,
35
+ ReplaceState,
36
+ ForceUpdate,
37
+} from './ReactUpdateQueue';
38
+import {NoWork} from './ReactFiberExpirationTime';
39
40
const fakeInternalInstance = {};
41
const isArray = Array.isArray;
42
43
let didWarnAboutStateAssignmentForComponent;
42
-let didWarnAboutUndefinedDerivedState;
44
let didWarnAboutUninitializedState;
45
let didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate;
46
let didWarnAboutLegacyLifecyclesAndDerivedState;
47
+let didWarnAboutUndefinedDerivedState;
48
+let warnOnUndefinedDerivedState;
49
let warnOnInvalidCallback;
50
51
if (__DEV__) {
52
didWarnAboutStateAssignmentForComponent = new Set();
50
- didWarnAboutUndefinedDerivedState = new Set();
53
didWarnAboutUninitializedState = new Set();
54
didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate = new Set();
55
didWarnAboutLegacyLifecyclesAndDerivedState = new Set();
56
+ didWarnAboutUndefinedDerivedState = new Set();
57
58
const didWarnOnInvalidCallback = new Set();
59
74
}
75
};
76
77
+ warnOnUndefinedDerivedState = function(workInProgress, partialState) {
78
+ if (partialState === undefined) {
79
+ const componentName = getComponentName(workInProgress) || 'Component';
80
+ if (!didWarnAboutUndefinedDerivedState.has(componentName)) {
81
+ didWarnAboutUndefinedDerivedState.add(componentName);
82
+ warning(
83
+ false,
84
+ '%s.getDerivedStateFromProps(): A valid state object (or null) must be returned. ' +
85
+ 'You have returned undefined.',
86
+ componentName,
87
+ );
88
+ }
89
+ }
90
+ };
91
+
92
// This is so gross but it's at least non-critical and can be removed if
93
// it causes problems. This is meant to give a nicer error message for
94
// ReactDOM15.unstable_renderSubtreeIntoContainer(reactDOM16Component,
110
});
111
Object.freeze(fakeInternalInstance);
112
}
95
-function callGetDerivedStateFromCatch(ctor: any, capturedValues: Array<mixed>) {
96
- const resultState = {};
97
- for (let i = 0; i < capturedValues.length; i++) {
98
- const capturedValue: CapturedValue<mixed> = (capturedValues[i]: any);
99
- const error = capturedValue.value;
100
- const partialState = ctor.getDerivedStateFromCatch.call(null, error);
101
- if (partialState !== null && partialState !== undefined) {
102
- Object.assign(resultState, partialState);
113
+
114
+export function applyDerivedStateFromProps(
115
+ workInProgress: Fiber,
116
+ getDerivedStateFromProps: (props: any, state: any) => any,
117
+ nextProps: any,
118
+) {
119
+ const prevState = workInProgress.memoizedState;
120
+
121
+ if (__DEV__) {
122
+ if (
123
+ debugRenderPhaseSideEffects ||
124
+ (debugRenderPhaseSideEffectsForStrictMode &&
125
+ workInProgress.mode & StrictMode)
126
+ ) {
127
+ // Invoke the function an extra time to help detect side-effects.
128
+ getDerivedStateFromProps(nextProps, prevState);
129
}
130
}
105
- return resultState;
131
+
132
+ const partialState = getDerivedStateFromProps(nextProps, prevState);
133
+
134
+ if (__DEV__) {
135
+ warnOnUndefinedDerivedState(workInProgress, partialState);
136
+ }
137
+ // Merge the partial state and the previous state.
138
+ const memoizedState =
139
+ partialState === null || partialState === undefined
140
+ ? prevState
141
+ : Object.assign({}, prevState, partialState);
142
+ workInProgress.memoizedState = memoizedState;
143
+
144
+ // Once the update queue is empty, persist the derived state onto the
145
+ // base state.
146
+ const updateQueue = workInProgress.updateQueue;
147
+ if (updateQueue !== null && updateQueue.expirationTime === NoWork) {
148
+ updateQueue.baseState = memoizedState;
149
+ }
150
}
151
152
export default function(
164
hasContextChanged,
165
} = legacyContext;
166
123
- // Class component state updater
124
- const updater = {
167
+ const classComponentUpdater = {
168
isMounted,
126
- enqueueSetState(instance, partialState, callback) {
127
- const fiber = ReactInstanceMap.get(instance);
128
- callback = callback === undefined ? null : callback;
129
- if (__DEV__) {
130
- warnOnInvalidCallback(callback, 'setState');
131
- }
169
+ enqueueSetState(inst, payload, callback) {
170
+ const fiber = ReactInstanceMap.get(inst);
171
const expirationTime = computeExpirationForFiber(fiber);
133
- const update = {
134
- expirationTime,
135
- partialState,
136
- callback,
137
- isReplace: false,
138
- isForced: false,
139
- capturedValue: null,
140
- next: null,
141
- };
142
- insertUpdateIntoFiber(fiber, update);
172
+
173
+ const update = createUpdate(expirationTime);
174
+ update.payload = payload;
175
+ if (callback !== undefined && callback !== null) {
176
+ if (__DEV__) {
177
+ warnOnInvalidCallback(callback, 'setState');
178
+ }
179
+ update.callback = callback;
180
+ }
181
+
182
+ enqueueUpdate(fiber, update, expirationTime);
183
scheduleWork(fiber, expirationTime);
184
},
145
- enqueueReplaceState(instance, state, callback) {
146
- const fiber = ReactInstanceMap.get(instance);
147
- callback = callback === undefined ? null : callback;
148
- if (__DEV__) {
149
- warnOnInvalidCallback(callback, 'replaceState');
150
- }
185
+ enqueueReplaceState(inst, payload, callback) {
186
+ const fiber = ReactInstanceMap.get(inst);
187
const expirationTime = computeExpirationForFiber(fiber);
152
- const update = {
153
- expirationTime,
154
- partialState: state,
155
- callback,
156
- isReplace: true,
157
- isForced: false,
158
- capturedValue: null,
159
- next: null,
160
- };
161
- insertUpdateIntoFiber(fiber, update);
188
+
189
+ const update = createUpdate(expirationTime);
190
+ update.tag = ReplaceState;
191
+ update.payload = payload;
192
+
193
+ if (callback !== undefined && callback !== null) {
194
+ if (__DEV__) {
195
+ warnOnInvalidCallback(callback, 'replaceState');
196
+ }
197
+ update.callback = callback;
198
+ }
199
+
200
+ enqueueUpdate(fiber, update, expirationTime);
201
scheduleWork(fiber, expirationTime);
202
},
164
- enqueueForceUpdate(instance, callback) {
165
- const fiber = ReactInstanceMap.get(instance);
166
- callback = callback === undefined ? null : callback;
167
- if (__DEV__) {
168
- warnOnInvalidCallback(callback, 'forceUpdate');
169
- }
203
+ enqueueForceUpdate(inst, callback) {
204
+ const fiber = ReactInstanceMap.get(inst);
205
const expirationTime = computeExpirationForFiber(fiber);
171
- const update = {
172
- expirationTime,
173
- partialState: null,
174
- callback,
175
- isReplace: false,
176
- isForced: true,
177
- capturedValue: null,
178
- next: null,
179
- };
180
- insertUpdateIntoFiber(fiber, update);
206
+
207
+ const update = createUpdate(expirationTime);
208
+ update.tag = ForceUpdate;
209
+
210
+ if (callback !== undefined && callback !== null) {
211
+ if (__DEV__) {
212
+ warnOnInvalidCallback(callback, 'forceUpdate');
213
+ }
214
+ update.callback = callback;
215
+ }
216
+
217
+ enqueueUpdate(fiber, update, expirationTime);
218
scheduleWork(fiber, expirationTime);
219
},
220
};
228
newContext,
229
) {
230
if (
194
- oldProps === null ||
195
- (workInProgress.updateQueue !== null &&
196
- workInProgress.updateQueue.hasForceUpdate)
231
+ workInProgress.updateQueue !== null &&
232
+ workInProgress.updateQueue.hasForceUpdate
233
) {
198
- // If the workInProgress already has an Update effect, return true
234
+ // If forceUpdate was called, disregard sCU.
235
return true;
236
}
237
456
}
457
}
458
423
- function resetInputPointers(workInProgress: Fiber, instance: any) {
424
- instance.props = workInProgress.memoizedProps;
425
- instance.state = workInProgress.memoizedState;
426
- }
427
-
459
function adoptClassInstance(workInProgress: Fiber, instance: any): void {
429
- instance.updater = updater;
460
+ instance.updater = classComponentUpdater;
461
workInProgress.stateNode = instance;
462
// The instance needs access to the fiber so that it can schedule updates
463
ReactInstanceMap.set(instance, workInProgress);
466
}
467
}
468
438
- function constructClassInstance(workInProgress: Fiber, props: any): any {
469
+ function constructClassInstance(
470
+ workInProgress: Fiber,
471
+ props: any,
472
+ renderExpirationTime: ExpirationTime,
473
+ ): any {
474
const ctor = workInProgress.type;
475
const unmaskedContext = getUnmaskedContext(workInProgress);
476
const needsContext = isContextConsumer(workInProgress);
479
: emptyObject;
480
481
// Instantiate twice to help detect side-effects.
447
- if (
448
- debugRenderPhaseSideEffects ||
449
- (debugRenderPhaseSideEffectsForStrictMode &&
450
- workInProgress.mode & StrictMode)
451
- ) {
452
- new ctor(props, context); // eslint-disable-line no-new
482
+ if (__DEV__) {
483
+ if (
484
+ debugRenderPhaseSideEffects ||
485
+ (debugRenderPhaseSideEffectsForStrictMode &&
486
+ workInProgress.mode & StrictMode)
487
+ ) {
488
+ new ctor(props, context); // eslint-disable-line no-new
489
+ }
490
}
491
492
const instance = new ctor(props, context);
456
- const state =
493
+ const state = (workInProgress.memoizedState =
494
instance.state !== null && instance.state !== undefined
495
? instance.state
459
- : null;
496
+ : null);
497
adoptClassInstance(workInProgress, instance);
498
499
if (__DEV__) {
582
}
583
}
584
548
- workInProgress.memoizedState = state;
549
-
550
- const partialState = callGetDerivedStateFromProps(
551
- workInProgress,
552
- instance,
553
- props,
554
- state,
555
- );
556
-
557
- if (partialState !== null && partialState !== undefined) {
558
- // Render-phase updates (like this) should not be added to the update queue,
559
- // So that multiple render passes do not enqueue multiple updates.
560
- // Instead, just synchronously merge the returned state into the instance.
561
- workInProgress.memoizedState = Object.assign(
562
- {},
563
- workInProgress.memoizedState,
564
- partialState,
565
- );
566
- }
567
-
585
// Cache unmasked context so we can avoid recreating masked context unless necessary.
586
// ReactFiberContext usually updates this cache but can't for newly-created instances.
587
if (needsContext) {
614
getComponentName(workInProgress) || 'Component',
615
);
616
}
600
- updater.enqueueReplaceState(instance, instance.state, null);
617
+ classComponentUpdater.enqueueReplaceState(instance, instance.state, null);
618
}
619
}
620
648
);
649
}
650
}
634
- updater.enqueueReplaceState(instance, instance.state, null);
635
- }
636
- }
637
-
638
- function callGetDerivedStateFromProps(
639
- workInProgress: Fiber,
640
- instance: any,
641
- nextProps: any,
642
- prevState: any,
643
- ) {
644
- const {type} = workInProgress;
645
-
646
- if (typeof type.getDerivedStateFromProps === 'function') {
647
- if (
648
- debugRenderPhaseSideEffects ||
649
- (debugRenderPhaseSideEffectsForStrictMode &&
650
- workInProgress.mode & StrictMode)
651
- ) {
652
- // Invoke method an extra time to help detect side-effects.
653
- type.getDerivedStateFromProps.call(null, nextProps, prevState);
654
- }
655
-
656
- const partialState = type.getDerivedStateFromProps.call(
657
- null,
658
- nextProps,
659
- prevState,
660
- );
661
-
662
- if (__DEV__) {
663
- if (partialState === undefined) {
664
- const componentName = getComponentName(workInProgress) || 'Component';
665
- if (!didWarnAboutUndefinedDerivedState.has(componentName)) {
666
- didWarnAboutUndefinedDerivedState.add(componentName);
667
- warning(
668
- false,
669
- '%s.getDerivedStateFromProps(): A valid state object (or null) must be returned. ' +
670
- 'You have returned undefined.',
671
- componentName,
672
- );
673
- }
674
- }
675
- }
676
-
677
- return partialState;
651
+ classComponentUpdater.enqueueReplaceState(instance, instance.state, null);
652
}
653
}
654
658
renderExpirationTime: ExpirationTime,
659
): void {
660
const ctor = workInProgress.type;
687
- const current = workInProgress.alternate;
661
662
if (__DEV__) {
663
checkClassInstance(workInProgress);
688
}
689
}
690
691
+ let updateQueue = workInProgress.updateQueue;
692
+ if (updateQueue !== null) {
693
+ processUpdateQueue(
694
+ workInProgress,
695
+ updateQueue,
696
+ props,
697
+ instance,
698
+ renderExpirationTime,
699
+ );
700
+ instance.state = workInProgress.memoizedState;
701
+ }
702
+
703
+ const getDerivedStateFromProps =
704
+ workInProgress.type.getDerivedStateFromProps;
705
+ if (typeof getDerivedStateFromProps === 'function') {
706
+ applyDerivedStateFromProps(
707
+ workInProgress,
708
+ getDerivedStateFromProps,
709
+ props,
710
+ );
711
+ instance.state = workInProgress.memoizedState;
712
+ }
713
+
714
// In order to support react-lifecycles-compat polyfilled components,
715
// Unsafe lifecycles should not be invoked for components using the new APIs.
716
if (
722
callComponentWillMount(workInProgress, instance);
723
// If we had additional state updates during this life-cycle, let's
724
// process them now.
729
- const updateQueue = workInProgress.updateQueue;
725
+ updateQueue = workInProgress.updateQueue;
726
if (updateQueue !== null) {
731
- instance.state = processUpdateQueue(
732
- current,
727
+ processUpdateQueue(
728
workInProgress,
729
updateQueue,
735
- instance,
730
props,
731
+ instance,
732
renderExpirationTime,
733
);
734
+ instance.state = workInProgress.memoizedState;
735
}
736
}
737
+
738
if (typeof instance.componentDidMount === 'function') {
739
workInProgress.effectTag |= Update;
740
}
746
): boolean {
747
const ctor = workInProgress.type;
748
const instance = workInProgress.stateNode;
752
- resetInputPointers(workInProgress, instance);
749
750
const oldProps = workInProgress.memoizedProps;
751
const newProps = workInProgress.pendingProps;
752
+ instance.props = oldProps;
753
+
754
const oldContext = instance.context;
755
const newUnmaskedContext = getUnmaskedContext(workInProgress);
756
const newContext = getMaskedContext(workInProgress, newUnmaskedContext);
757
758
+ const getDerivedStateFromProps = ctor.getDerivedStateFromProps;
759
const hasNewLifecycles =
761
- typeof ctor.getDerivedStateFromProps === 'function' ||
760
+ typeof getDerivedStateFromProps === 'function' ||
761
typeof instance.getSnapshotBeforeUpdate === 'function';
762
763
// Note: During these life-cycles, instance.props/instance.state are what
781
}
782
}
783
785
- // Compute the next state using the memoized state and the update queue.
784
const oldState = workInProgress.memoizedState;
787
- // TODO: Previous state can be null.
788
- let newState;
789
- let derivedStateFromCatch;
790
- if (workInProgress.updateQueue !== null) {
791
- newState = processUpdateQueue(
792
- null,
785
+ let newState = (instance.state = oldState);
786
+ let updateQueue = workInProgress.updateQueue;
787
+ if (updateQueue !== null) {
788
+ processUpdateQueue(
789
workInProgress,
794
- workInProgress.updateQueue,
795
- instance,
790
+ updateQueue,
791
newProps,
792
+ instance,
793
renderExpirationTime,
794
);
799
-
800
- let updateQueue = workInProgress.updateQueue;
801
- if (
802
- updateQueue !== null &&
803
- updateQueue.capturedValues !== null &&
804
- (enableGetDerivedStateFromCatch &&
805
- typeof ctor.getDerivedStateFromCatch === 'function')
806
- ) {
807
- const capturedValues = updateQueue.capturedValues;
808
- // Don't remove these from the update queue yet. We need them in
809
- // finishClassComponent. Do the reset there.
810
- // TODO: This is awkward. Refactor class components.
811
- // updateQueue.capturedValues = null;
812
- derivedStateFromCatch = callGetDerivedStateFromCatch(
813
- ctor,
814
- capturedValues,
815
- );
816
- }
817
- } else {
818
- newState = oldState;
795
+ newState = workInProgress.memoizedState;
796
}
797
821
- let derivedStateFromProps;
822
- if (oldProps !== newProps) {
823
- // The prevState parameter should be the partially updated state.
824
- // Otherwise, spreading state in return values could override updates.
825
- derivedStateFromProps = callGetDerivedStateFromProps(
798
+ if (typeof getDerivedStateFromProps === 'function') {
799
+ applyDerivedStateFromProps(
800
workInProgress,
827
- instance,
801
+ getDerivedStateFromProps,
802
newProps,
829
- newState,
803
);
831
- }
832
-
833
- if (derivedStateFromProps !== null && derivedStateFromProps !== undefined) {
834
- // Render-phase updates (like this) should not be added to the update queue,
835
- // So that multiple render passes do not enqueue multiple updates.
836
- // Instead, just synchronously merge the returned state into the instance.
837
- newState =
838
- newState === null || newState === undefined
839
- ? derivedStateFromProps
840
- : Object.assign({}, newState, derivedStateFromProps);
841
-
842
- // Update the base state of the update queue.
843
- // FIXME: This is getting ridiculous. Refactor plz!
844
- const updateQueue = workInProgress.updateQueue;
845
- if (updateQueue !== null) {
846
- updateQueue.baseState = Object.assign(
847
- {},
848
- updateQueue.baseState,
849
- derivedStateFromProps,
850
- );
851
- }
852
- }
853
- if (derivedStateFromCatch !== null && derivedStateFromCatch !== undefined) {
854
- // Render-phase updates (like this) should not be added to the update queue,
855
- // So that multiple render passes do not enqueue multiple updates.
856
- // Instead, just synchronously merge the returned state into the instance.
857
- newState =
858
- newState === null || newState === undefined
859
- ? derivedStateFromCatch
860
- : Object.assign({}, newState, derivedStateFromCatch);
861
-
862
- // Update the base state of the update queue.
863
- // FIXME: This is getting ridiculous. Refactor plz!
864
- const updateQueue = workInProgress.updateQueue;
865
- if (updateQueue !== null) {
866
- updateQueue.baseState = Object.assign(
867
- {},
868
- updateQueue.baseState,
869
- derivedStateFromCatch,
870
- );
871
- }
804
+ newState = workInProgress.memoizedState;
805
}
806
807
if (
858
}
859
860
// If shouldComponentUpdate returned false, we should still update the
928
- // memoized props/state to indicate that this work can be reused.
929
- memoizeProps(workInProgress, newProps);
930
- memoizeState(workInProgress, newState);
861
+ // memoized state to indicate that this work can be reused.
862
+ workInProgress.memoizedProps = newProps;
863
+ workInProgress.memoizedState = newState;
864
}
865
866
// Update the existing instance's state, props, and context pointers even
880
): boolean {
881
const ctor = workInProgress.type;
882
const instance = workInProgress.stateNode;
950
- resetInputPointers(workInProgress, instance);
883
884
const oldProps = workInProgress.memoizedProps;
885
const newProps = workInProgress.pendingProps;
886
+ instance.props = oldProps;
887
+
888
const oldContext = instance.context;
889
const newUnmaskedContext = getUnmaskedContext(workInProgress);
890
const newContext = getMaskedContext(workInProgress, newUnmaskedContext);
891
892
+ const getDerivedStateFromProps = ctor.getDerivedStateFromProps;
893
const hasNewLifecycles =
959
- typeof ctor.getDerivedStateFromProps === 'function' ||
894
+ typeof getDerivedStateFromProps === 'function' ||
895
typeof instance.getSnapshotBeforeUpdate === 'function';
896
897
// Note: During these life-cycles, instance.props/instance.state are what
915
}
916
}
917
983
- // Compute the next state using the memoized state and the update queue.
918
const oldState = workInProgress.memoizedState;
985
- // TODO: Previous state can be null.
986
- let newState;
987
- let derivedStateFromCatch;
988
-
989
- if (workInProgress.updateQueue !== null) {
990
- newState = processUpdateQueue(
991
- current,
919
+ let newState = (instance.state = oldState);
920
+ let updateQueue = workInProgress.updateQueue;
921
+ if (updateQueue !== null) {
922
+ processUpdateQueue(
923
workInProgress,
993
- workInProgress.updateQueue,
994
- instance,
924
+ updateQueue,
925
newProps,
926
+ instance,
927
renderExpirationTime,
928
);
998
-
999
- let updateQueue = workInProgress.updateQueue;
1000
- if (
1001
- updateQueue !== null &&
1002
- updateQueue.capturedValues !== null &&
1003
- (enableGetDerivedStateFromCatch &&
1004
- typeof ctor.getDerivedStateFromCatch === 'function')
1005
- ) {
1006
- const capturedValues = updateQueue.capturedValues;
1007
- // Don't remove these from the update queue yet. We need them in
1008
- // finishClassComponent. Do the reset there.
1009
- // TODO: This is awkward. Refactor class components.
1010
- // updateQueue.capturedValues = null;
1011
- derivedStateFromCatch = callGetDerivedStateFromCatch(
1012
- ctor,
1013
- capturedValues,
1014
- );
1015
- }
1016
- } else {
1017
- newState = oldState;
929
+ newState = workInProgress.memoizedState;
930
}
931
1020
- let derivedStateFromProps;
1021
- if (oldProps !== newProps) {
1022
- // The prevState parameter should be the partially updated state.
1023
- // Otherwise, spreading state in return values could override updates.
1024
- derivedStateFromProps = callGetDerivedStateFromProps(
932
+ if (typeof getDerivedStateFromProps === 'function') {
933
+ applyDerivedStateFromProps(
934
workInProgress,
1026
- instance,
935
+ getDerivedStateFromProps,
936
newProps,
1028
- newState,
937
);
1030
- }
1031
-
1032
- if (derivedStateFromProps !== null && derivedStateFromProps !== undefined) {
1033
- // Render-phase updates (like this) should not be added to the update queue,
1034
- // So that multiple render passes do not enqueue multiple updates.
1035
- // Instead, just synchronously merge the returned state into the instance.
1036
- newState =
1037
- newState === null || newState === undefined
1038
- ? derivedStateFromProps
1039
- : Object.assign({}, newState, derivedStateFromProps);
1040
-
1041
- // Update the base state of the update queue.
1042
- // FIXME: This is getting ridiculous. Refactor plz!
1043
- const updateQueue = workInProgress.updateQueue;
1044
- if (updateQueue !== null) {
1045
- updateQueue.baseState = Object.assign(
1046
- {},
1047
- updateQueue.baseState,
1048
- derivedStateFromProps,
1049
- );
1050
- }
1051
- }
1052
- if (derivedStateFromCatch !== null && derivedStateFromCatch !== undefined) {
1053
- // Render-phase updates (like this) should not be added to the update queue,
1054
- // So that multiple render passes do not enqueue multiple updates.
1055
- // Instead, just synchronously merge the returned state into the instance.
1056
- newState =
1057
- newState === null || newState === undefined
1058
- ? derivedStateFromCatch
1059
- : Object.assign({}, newState, derivedStateFromCatch);
1060
-
1061
- // Update the base state of the update queue.
1062
- // FIXME: This is getting ridiculous. Refactor plz!
1063
- const updateQueue = workInProgress.updateQueue;
1064
- if (updateQueue !== null) {
1065
- updateQueue.baseState = Object.assign(
1066
- {},
1067
- updateQueue.baseState,
1068
- derivedStateFromCatch,
1069
- );
1070
- }
938
+ newState = workInProgress.memoizedState;
939
}
940
941
if (
1022
1023
// If shouldComponentUpdate returned false, we should still update the
1024
// memoized props/state to indicate that this work can be reused.
1157
- memoizeProps(workInProgress, newProps);
1158
- memoizeState(workInProgress, newState);
1025
+ workInProgress.memoizedProps = newProps;
1026
+ workInProgress.memoizedState = newState;
1027
}
1028
1029
// Update the existing instance's state, props, and context pointers even
1037
1038
return {
1039
adoptClassInstance,
1172
- callGetDerivedStateFromProps,
1040
constructClassInstance,
1041
mountClassInstance,
1042
resumeMountClassInstance,