@@ -23,7 +23,6 @@ import {
23
23
enableProfilerCommitHooks ,
24
24
enableProfilerNestedUpdatePhase ,
25
25
enableSchedulingProfiler ,
26
- enableUseEffectCRUDOverload ,
27
26
enableViewTransition ,
28
27
enableFragmentRefs ,
29
28
} from 'shared/ReactFeatureFlags' ;
@@ -62,7 +61,6 @@ import {
62
61
Layout as HookLayout ,
63
62
Insertion as HookInsertion ,
64
63
Passive as HookPassive ,
65
- HasEffect as HookHasEffect ,
66
64
} from './ReactHookEffectTags' ;
67
65
import { didWarnAboutReassigningProps } from './ReactFiberBeginWork' ;
68
66
import {
@@ -84,10 +82,6 @@ import {
84
82
} from './ReactFiberCallUserSpace' ;
85
83
86
84
import { runWithFiberInDEV } from './ReactCurrentFiber' ;
87
- import {
88
- ResourceEffectIdentityKind ,
89
- ResourceEffectUpdateKind ,
90
- } from './ReactFiberHooks' ;
91
85
92
86
function shouldProfile ( current : Fiber ) : boolean {
93
87
return (
@@ -164,91 +158,19 @@ export function commitHookEffectListMount(
164
158
165
159
// Mount
166
160
let destroy ;
167
- if ( enableUseEffectCRUDOverload ) {
168
- if ( effect . resourceKind === ResourceEffectIdentityKind ) {
169
- if ( __DEV__ ) {
170
- effect . inst . resource = runWithFiberInDEV (
171
- finishedWork ,
172
- callCreateInDEV ,
173
- effect ,
174
- ) ;
175
- if ( effect . inst . resource == null ) {
176
- console . error (
177
- 'useEffect must provide a callback which returns a resource. ' +
178
- 'If a managed resource is not needed here, do not provide an updater or ' +
179
- 'destroy callback. Received %s' ,
180
- effect . inst . resource ,
181
- ) ;
182
- }
183
- } else {
184
- effect . inst . resource = effect . create ( ) ;
185
- }
186
- destroy = effect . inst . destroy ;
187
- }
188
- if ( effect . resourceKind === ResourceEffectUpdateKind ) {
189
- if (
190
- // We don't want to fire updates on remount during Activity
191
- ( flags & HookHasEffect ) > 0 &&
192
- typeof effect . update === 'function' &&
193
- effect . inst . resource != null
194
- ) {
195
- // TODO(@poteto) what about multiple updates?
196
- if ( __DEV__ ) {
197
- runWithFiberInDEV ( finishedWork , callCreateInDEV , effect ) ;
198
- } else {
199
- effect . update ( effect . inst . resource ) ;
200
- }
201
- }
202
- }
203
- }
204
161
if ( __DEV__ ) {
205
162
if ( ( flags & HookInsertion ) !== NoHookEffect ) {
206
163
setIsRunningInsertionEffect ( true ) ;
207
164
}
208
- if ( enableUseEffectCRUDOverload ) {
209
- if ( effect . resourceKind == null ) {
210
- destroy = runWithFiberInDEV (
211
- finishedWork ,
212
- callCreateInDEV ,
213
- effect ,
214
- ) ;
215
- }
216
- } else {
217
- destroy = runWithFiberInDEV (
218
- finishedWork ,
219
- callCreateInDEV ,
220
- effect ,
221
- ) ;
222
- }
165
+ destroy = runWithFiberInDEV ( finishedWork , callCreateInDEV , effect ) ;
223
166
if ( ( flags & HookInsertion ) !== NoHookEffect ) {
224
167
setIsRunningInsertionEffect ( false ) ;
225
168
}
226
169
} else {
227
- if ( enableUseEffectCRUDOverload ) {
228
- if ( effect . resourceKind == null ) {
229
- const create = effect . create ;
230
- const inst = effect . inst ;
231
- destroy = create ( ) ;
232
- inst . destroy = destroy ;
233
- }
234
- } else {
235
- if ( effect . resourceKind != null ) {
236
- if ( __DEV__ ) {
237
- console . error (
238
- 'Expected only SimpleEffects when enableUseEffectCRUDOverload is disabled, ' +
239
- 'got %s' ,
240
- effect . resourceKind ,
241
- ) ;
242
- }
243
- }
244
- const create = effect . create ;
245
- const inst = effect . inst ;
246
- // $FlowFixMe[incompatible-type] (@poteto)
247
- // $FlowFixMe[not-a-function] (@poteto)
248
- destroy = create ( ) ;
249
- // $FlowFixMe[incompatible-type] (@poteto)
250
- inst . destroy = destroy ;
251
- }
170
+ const create = effect . create ;
171
+ const inst = effect . inst ;
172
+ destroy = create ( ) ;
173
+ inst . destroy = destroy ;
252
174
}
253
175
254
176
if ( enableSchedulingProfiler ) {
@@ -338,13 +260,7 @@ export function commitHookEffectListUnmount(
338
260
const inst = effect . inst ;
339
261
const destroy = inst . destroy ;
340
262
if ( destroy !== undefined ) {
341
- if ( enableUseEffectCRUDOverload ) {
342
- if ( effect . resourceKind == null ) {
343
- inst . destroy = undefined ;
344
- }
345
- } else {
346
- inst . destroy = undefined ;
347
- }
263
+ inst . destroy = undefined ;
348
264
if ( enableSchedulingProfiler ) {
349
265
if ( ( flags & HookPassive ) !== NoHookEffect ) {
350
266
markComponentPassiveEffectUnmountStarted ( finishedWork ) ;
@@ -358,41 +274,7 @@ export function commitHookEffectListUnmount(
358
274
setIsRunningInsertionEffect ( true ) ;
359
275
}
360
276
}
361
- if ( enableUseEffectCRUDOverload ) {
362
- if (
363
- effect . resourceKind === ResourceEffectIdentityKind &&
364
- effect . inst . resource != null
365
- ) {
366
- safelyCallDestroy (
367
- finishedWork ,
368
- nearestMountedAncestor ,
369
- destroy ,
370
- effect . inst . resource ,
371
- ) ;
372
- if ( effect . next . resourceKind === ResourceEffectUpdateKind ) {
373
- // $FlowFixMe[prop-missing] (@poteto)
374
- effect . next . update = undefined ;
375
- } else {
376
- if ( __DEV__ ) {
377
- console . error (
378
- 'Expected a ResourceEffectUpdateKind to follow ResourceEffectIdentityKind, ' +
379
- 'got %s. This is a bug in React.' ,
380
- effect . next . resourceKind ,
381
- ) ;
382
- }
383
- }
384
- effect . inst . resource = null ;
385
- }
386
- if ( effect . resourceKind == null ) {
387
- safelyCallDestroy (
388
- finishedWork ,
389
- nearestMountedAncestor ,
390
- destroy ,
391
- ) ;
392
- }
393
- } else {
394
- safelyCallDestroy ( finishedWork , nearestMountedAncestor , destroy ) ;
395
- }
277
+ safelyCallDestroy ( finishedWork , nearestMountedAncestor , destroy ) ;
396
278
if ( __DEV__ ) {
397
279
if ( ( flags & HookInsertion ) !== NoHookEffect ) {
398
280
setIsRunningInsertionEffect ( false ) ;
0 commit comments