@@ -19,8 +19,7 @@ import {
1919 warnAboutDeprecatedLifecycles ,
2020} from 'shared/ReactFeatureFlags' ;
2121import ReactStrictModeWarnings from './ReactStrictModeWarnings' ;
22- import { isMounted } from 'react-reconciler/reflection' ;
23- import { get as getInstance , set as setInstance } from 'shared/ReactInstanceMap' ;
22+ import { set as setInstance } from 'shared/ReactInstanceMap' ;
2423import shallowEqual from 'shared/shallowEqual' ;
2524import getComponentName from 'shared/getComponentName' ;
2625import invariant from 'shared/invariant' ;
@@ -31,13 +30,9 @@ import {resolveDefaultProps} from './ReactFiberLazyComponent';
3130import { StrictMode } from './ReactTypeOfMode' ;
3231
3332import {
34- enqueueUpdate ,
3533 processUpdateQueue ,
3634 checkHasForceUpdateAfterProcessing ,
3735 resetHasForceUpdateBeforeProcessing ,
38- createUpdate ,
39- ReplaceState ,
40- ForceUpdate ,
4136 initializeUpdateQueue ,
4237 cloneUpdateQueue ,
4338} from './ReactUpdateQueue' ;
@@ -50,12 +45,7 @@ import {
5045 emptyContextObject ,
5146} from './ReactFiberContext' ;
5247import { readContext } from './ReactFiberNewContext' ;
53- import {
54- requestCurrentTimeForUpdate ,
55- computeExpirationForFiber ,
56- scheduleWork ,
57- } from './ReactFiberWorkLoop' ;
58- import { requestCurrentSuspenseConfig } from './ReactFiberSuspenseConfig' ;
48+ import { classComponentUpdater } from './ReactFiberTransition' ;
5949
6050const fakeInternalInstance = { } ;
6151const isArray = Array . isArray ;
@@ -70,7 +60,6 @@ let didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate;
7060let didWarnAboutLegacyLifecyclesAndDerivedState ;
7161let didWarnAboutUndefinedDerivedState ;
7262let warnOnUndefinedDerivedState ;
73- let warnOnInvalidCallback ;
7463let didWarnAboutDirectlyAssigningPropsToState ;
7564let didWarnAboutContextTypeAndContextTypes ;
7665let didWarnAboutInvalidateContextType ;
@@ -85,24 +74,6 @@ if (__DEV__) {
8574 didWarnAboutContextTypeAndContextTypes = new Set ( ) ;
8675 didWarnAboutInvalidateContextType = new Set ( ) ;
8776
88- const didWarnOnInvalidCallback = new Set ( ) ;
89-
90- warnOnInvalidCallback = function ( callback : mixed , callerName : string ) {
91- if ( callback === null || typeof callback === 'function' ) {
92- return ;
93- }
94- const key = `${ callerName } _${ ( callback : any ) } ` ;
95- if ( ! didWarnOnInvalidCallback . has ( key ) ) {
96- didWarnOnInvalidCallback . add ( key ) ;
97- console . error (
98- '%s(...): Expected the last optional `callback` argument to be a ' +
99- 'function. Instead received: %s.' ,
100- callerName ,
101- callback ,
102- ) ;
103- }
104- } ;
105-
10677 warnOnUndefinedDerivedState = function ( type , partialState ) {
10778 if ( partialState === undefined ) {
10879 const componentName = getComponentName ( type ) || 'Component' ;
@@ -178,79 +149,6 @@ export function applyDerivedStateFromProps(
178149 }
179150}
180151
181- const classComponentUpdater = {
182- isMounted,
183- enqueueSetState ( inst , payload , callback ) {
184- const fiber = getInstance ( inst ) ;
185- const currentTime = requestCurrentTimeForUpdate ( ) ;
186- const suspenseConfig = requestCurrentSuspenseConfig ( ) ;
187- const expirationTime = computeExpirationForFiber (
188- currentTime ,
189- fiber ,
190- suspenseConfig ,
191- ) ;
192-
193- const update = createUpdate ( currentTime , expirationTime , suspenseConfig ) ;
194- update . payload = payload ;
195- if ( callback !== undefined && callback !== null ) {
196- if ( __DEV__ ) {
197- warnOnInvalidCallback ( callback , 'setState' ) ;
198- }
199- update . callback = callback ;
200- }
201-
202- enqueueUpdate ( fiber , update ) ;
203- scheduleWork ( fiber , expirationTime ) ;
204- } ,
205- enqueueReplaceState ( inst , payload , callback ) {
206- const fiber = getInstance ( inst ) ;
207- const currentTime = requestCurrentTimeForUpdate ( ) ;
208- const suspenseConfig = requestCurrentSuspenseConfig ( ) ;
209- const expirationTime = computeExpirationForFiber (
210- currentTime ,
211- fiber ,
212- suspenseConfig ,
213- ) ;
214-
215- const update = createUpdate ( currentTime , expirationTime , suspenseConfig ) ;
216- update . tag = ReplaceState ;
217- update . payload = payload ;
218-
219- if ( callback !== undefined && callback !== null ) {
220- if ( __DEV__ ) {
221- warnOnInvalidCallback ( callback , 'replaceState' ) ;
222- }
223- update . callback = callback ;
224- }
225-
226- enqueueUpdate ( fiber , update ) ;
227- scheduleWork ( fiber , expirationTime ) ;
228- } ,
229- enqueueForceUpdate ( inst , callback ) {
230- const fiber = getInstance ( inst ) ;
231- const currentTime = requestCurrentTimeForUpdate ( ) ;
232- const suspenseConfig = requestCurrentSuspenseConfig ( ) ;
233- const expirationTime = computeExpirationForFiber (
234- currentTime ,
235- fiber ,
236- suspenseConfig ,
237- ) ;
238-
239- const update = createUpdate ( currentTime , expirationTime , suspenseConfig ) ;
240- update . tag = ForceUpdate ;
241-
242- if ( callback !== undefined && callback !== null ) {
243- if ( __DEV__ ) {
244- warnOnInvalidCallback ( callback , 'forceUpdate' ) ;
245- }
246- update . callback = callback ;
247- }
248-
249- enqueueUpdate ( fiber , update ) ;
250- scheduleWork ( fiber , expirationTime ) ;
251- } ,
252- } ;
253-
254152function checkShouldComponentUpdate (
255153 workInProgress ,
256154 ctor ,
0 commit comments