@@ -23,7 +23,6 @@ import {
2323 enableProfilerCommitHooks ,
2424 enableProfilerNestedUpdatePhase ,
2525 enableSchedulingProfiler ,
26- enableUseEffectCRUDOverload ,
2726 enableViewTransition ,
2827 enableFragmentRefs ,
2928} from 'shared/ReactFeatureFlags' ;
@@ -62,7 +61,6 @@ import {
6261 Layout as HookLayout ,
6362 Insertion as HookInsertion ,
6463 Passive as HookPassive ,
65- HasEffect as HookHasEffect ,
6664} from './ReactHookEffectTags' ;
6765import { didWarnAboutReassigningProps } from './ReactFiberBeginWork' ;
6866import {
@@ -84,10 +82,6 @@ import {
8482} from './ReactFiberCallUserSpace' ;
8583
8684import { runWithFiberInDEV } from './ReactCurrentFiber' ;
87- import {
88- ResourceEffectIdentityKind ,
89- ResourceEffectUpdateKind ,
90- } from './ReactFiberHooks' ;
9185
9286function shouldProfile ( current : Fiber ) : boolean {
9387 return (
@@ -164,91 +158,19 @@ export function commitHookEffectListMount(
164158
165159 // Mount
166160 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- }
204161 if ( __DEV__ ) {
205162 if ( ( flags & HookInsertion ) !== NoHookEffect ) {
206163 setIsRunningInsertionEffect ( true ) ;
207164 }
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 ) ;
223166 if ( ( flags & HookInsertion ) !== NoHookEffect ) {
224167 setIsRunningInsertionEffect ( false ) ;
225168 }
226169 } 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 ;
252174 }
253175
254176 if ( enableSchedulingProfiler ) {
@@ -338,13 +260,7 @@ export function commitHookEffectListUnmount(
338260 const inst = effect . inst ;
339261 const destroy = inst . destroy ;
340262 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 ;
348264 if ( enableSchedulingProfiler ) {
349265 if ( ( flags & HookPassive ) !== NoHookEffect ) {
350266 markComponentPassiveEffectUnmountStarted ( finishedWork ) ;
@@ -358,41 +274,7 @@ export function commitHookEffectListUnmount(
358274 setIsRunningInsertionEffect ( true ) ;
359275 }
360276 }
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 ) ;
396278 if ( __DEV__ ) {
397279 if ( ( flags & HookInsertion ) !== NoHookEffect ) {
398280 setIsRunningInsertionEffect ( false ) ;
0 commit comments