Skip to content

Commit 4ed1b92

Browse files
gaearonacdlite
authored andcommitted
Remove dead branches
1 parent 763d5f2 commit 4ed1b92

File tree

5 files changed

+21
-248
lines changed

5 files changed

+21
-248
lines changed

packages/react-dom/src/__tests__/ReactDOMServerPartialHydration-test.internal.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -367,13 +367,9 @@ describe('ReactDOMServerPartialHydration', () => {
367367
// This is a new node.
368368
expect(span).not.toBe(span2);
369369

370-
if (gate(flags => flags.new)) {
371-
// The effects list refactor causes this to be null because the Suspense Offscreen's child
372-
// is null. However, since we can't hydrate Suspense in legacy this change in behavior is ok
373-
expect(ref.current).toBe(null);
374-
} else {
375-
expect(ref.current).toBe(span2);
376-
}
370+
// The effects list refactor causes this to be null because the Suspense Offscreen's child
371+
// is null. However, since we can't hydrate Suspense in legacy this change in behavior is ok
372+
expect(ref.current).toBe(null);
377373

378374
// Resolving the promise should render the final content.
379375
suspend = false;

packages/react-reconciler/src/__tests__/DebugTracing-test.internal.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -376,14 +376,14 @@ describe('DebugTracing', () => {
376376
expect(logs).toEqual([
377377
'group: ⚛️ render (0b0000000000000000000001000000000)',
378378
'log: ⚛️ Example updated state (0b0000000000000000000001000000000)',
379-
'log: ⚛️ Example updated state (0b0000000000000000000001000000000)', // debugRenderPhaseSideEffectsForStrictMode
379+
'log: ⚛️ Example updated state (0b0000000000000000000001000000000)',
380380
'groupEnd: ⚛️ render (0b0000000000000000000001000000000)',
381381
]);
382382
} else {
383383
expect(logs).toEqual([
384384
'group: ⚛️ render (0b0000000000000000000001000000000)',
385385
'log: ⚛️ Example updated state (0b0000000000000000000010000000000)',
386-
'log: ⚛️ Example updated state (0b0000000000000000000010000000000)', // debugRenderPhaseSideEffectsForStrictMode
386+
'log: ⚛️ Example updated state (0b0000000000000000000010000000000)',
387387
'groupEnd: ⚛️ render (0b0000000000000000000001000000000)',
388388
]);
389389
}

packages/react-reconciler/src/__tests__/ReactHooksWithNoopRenderer-test.js

Lines changed: 5 additions & 183 deletions
Original file line numberDiff line numberDiff line change
@@ -2356,7 +2356,6 @@ describe('ReactHooksWithNoopRenderer', () => {
23562356
describe('errors thrown in passive destroy function within unmounted trees', () => {
23572357
let BrokenUseEffectCleanup;
23582358
let ErrorBoundary;
2359-
let DerivedStateOnlyErrorBoundary;
23602359
let LogOnlyErrorBoundary;
23612360

23622361
beforeEach(() => {
@@ -2395,28 +2394,6 @@ describe('ReactHooksWithNoopRenderer', () => {
23952394
}
23962395
};
23972396

2398-
DerivedStateOnlyErrorBoundary = class extends React.Component {
2399-
state = {error: null};
2400-
static getDerivedStateFromError(error) {
2401-
Scheduler.unstable_yieldValue(
2402-
`DerivedStateOnlyErrorBoundary static getDerivedStateFromError`,
2403-
);
2404-
return {error};
2405-
}
2406-
render() {
2407-
if (this.state.error) {
2408-
Scheduler.unstable_yieldValue(
2409-
'DerivedStateOnlyErrorBoundary render error',
2410-
);
2411-
return <span prop="DerivedStateOnlyErrorBoundary fallback" />;
2412-
}
2413-
Scheduler.unstable_yieldValue(
2414-
'DerivedStateOnlyErrorBoundary render success',
2415-
);
2416-
return this.props.children || null;
2417-
}
2418-
};
2419-
24202397
LogOnlyErrorBoundary = class extends React.Component {
24212398
componentDidCatch(error, info) {
24222399
Scheduler.unstable_yieldValue(
@@ -2430,162 +2407,7 @@ describe('ReactHooksWithNoopRenderer', () => {
24302407
};
24312408
});
24322409

2433-
// @gate old
2434-
it('should call componentDidCatch() for the nearest unmounted log-only boundary', () => {
2435-
function Conditional({showChildren}) {
2436-
if (showChildren) {
2437-
return (
2438-
<LogOnlyErrorBoundary>
2439-
<BrokenUseEffectCleanup />
2440-
</LogOnlyErrorBoundary>
2441-
);
2442-
} else {
2443-
return null;
2444-
}
2445-
}
2446-
2447-
act(() => {
2448-
ReactNoop.render(
2449-
<ErrorBoundary>
2450-
<Conditional showChildren={true} />
2451-
</ErrorBoundary>,
2452-
);
2453-
});
2454-
2455-
expect(Scheduler).toHaveYielded([
2456-
'ErrorBoundary render success',
2457-
'LogOnlyErrorBoundary render',
2458-
'BrokenUseEffectCleanup useEffect',
2459-
]);
2460-
2461-
act(() => {
2462-
ReactNoop.render(
2463-
<ErrorBoundary>
2464-
<Conditional showChildren={false} />
2465-
</ErrorBoundary>,
2466-
);
2467-
expect(Scheduler).toFlushAndYieldThrough([
2468-
'ErrorBoundary render success',
2469-
]);
2470-
});
2471-
2472-
expect(Scheduler).toHaveYielded([
2473-
'BrokenUseEffectCleanup useEffect destroy',
2474-
'LogOnlyErrorBoundary componentDidCatch',
2475-
]);
2476-
});
2477-
2478-
// @gate old
2479-
it('should call componentDidCatch() for the nearest unmounted logging-capable boundary', () => {
2480-
function Conditional({showChildren}) {
2481-
if (showChildren) {
2482-
return (
2483-
<ErrorBoundary>
2484-
<BrokenUseEffectCleanup />
2485-
</ErrorBoundary>
2486-
);
2487-
} else {
2488-
return null;
2489-
}
2490-
}
2491-
2492-
act(() => {
2493-
ReactNoop.render(
2494-
<ErrorBoundary>
2495-
<Conditional showChildren={true} />
2496-
</ErrorBoundary>,
2497-
);
2498-
});
2499-
2500-
expect(Scheduler).toHaveYielded([
2501-
'ErrorBoundary render success',
2502-
'ErrorBoundary render success',
2503-
'BrokenUseEffectCleanup useEffect',
2504-
]);
2505-
2506-
act(() => {
2507-
ReactNoop.render(
2508-
<ErrorBoundary>
2509-
<Conditional showChildren={false} />
2510-
</ErrorBoundary>,
2511-
);
2512-
expect(Scheduler).toFlushAndYieldThrough([
2513-
'ErrorBoundary render success',
2514-
]);
2515-
});
2516-
2517-
expect(Scheduler).toHaveYielded([
2518-
'BrokenUseEffectCleanup useEffect destroy',
2519-
'ErrorBoundary componentDidCatch',
2520-
]);
2521-
});
2522-
2523-
// @gate old
2524-
it('should not call getDerivedStateFromError for unmounted error boundaries', () => {
2525-
function Conditional({showChildren}) {
2526-
if (showChildren) {
2527-
return (
2528-
<ErrorBoundary>
2529-
<BrokenUseEffectCleanup />
2530-
</ErrorBoundary>
2531-
);
2532-
} else {
2533-
return null;
2534-
}
2535-
}
2536-
2537-
act(() => {
2538-
ReactNoop.render(<Conditional showChildren={true} />);
2539-
});
2540-
2541-
expect(Scheduler).toHaveYielded([
2542-
'ErrorBoundary render success',
2543-
'BrokenUseEffectCleanup useEffect',
2544-
]);
2545-
2546-
act(() => {
2547-
ReactNoop.render(<Conditional showChildren={false} />);
2548-
});
2549-
2550-
expect(Scheduler).toHaveYielded([
2551-
'BrokenUseEffectCleanup useEffect destroy',
2552-
'ErrorBoundary componentDidCatch',
2553-
]);
2554-
});
2555-
2556-
// @gate old
2557-
it('should not throw if there are no unmounted logging-capable boundaries to call', () => {
2558-
function Conditional({showChildren}) {
2559-
if (showChildren) {
2560-
return (
2561-
<DerivedStateOnlyErrorBoundary>
2562-
<BrokenUseEffectCleanup />
2563-
</DerivedStateOnlyErrorBoundary>
2564-
);
2565-
} else {
2566-
return null;
2567-
}
2568-
}
2569-
2570-
act(() => {
2571-
ReactNoop.render(<Conditional showChildren={true} />);
2572-
});
2573-
2574-
expect(Scheduler).toHaveYielded([
2575-
'DerivedStateOnlyErrorBoundary render success',
2576-
'BrokenUseEffectCleanup useEffect',
2577-
]);
2578-
2579-
act(() => {
2580-
ReactNoop.render(<Conditional showChildren={false} />);
2581-
});
2582-
2583-
expect(Scheduler).toHaveYielded([
2584-
'BrokenUseEffectCleanup useEffect destroy',
2585-
]);
2586-
});
2587-
2588-
// @gate new
2410+
// @gate skipUnmountedBoundaries
25892411
it('should use the nearest still-mounted boundary if there are no unmounted boundaries', () => {
25902412
act(() => {
25912413
ReactNoop.render(
@@ -2611,8 +2433,8 @@ describe('ReactHooksWithNoopRenderer', () => {
26112433
]);
26122434
});
26132435

2614-
// @gate new
2615-
it('should skip unmounted boundaries and use the nearest still-mounted boundary', () => {
2436+
// @gate skipUnmountedBoundaries
2437+
it('should skip unmounted boundaries and use the nearest still-mounted boundary', () => {
26162438
function Conditional({showChildren}) {
26172439
if (showChildren) {
26182440
return (
@@ -2654,7 +2476,7 @@ describe('ReactHooksWithNoopRenderer', () => {
26542476
]);
26552477
});
26562478

2657-
// @gate new
2479+
// @gate skipUnmountedBoundaries
26582480
it('should call getDerivedStateFromError in the nearest still-mounted boundary', () => {
26592481
function Conditional({showChildren}) {
26602482
if (showChildren) {
@@ -2698,7 +2520,7 @@ describe('ReactHooksWithNoopRenderer', () => {
26982520
]);
26992521
});
27002522

2701-
// @gate new
2523+
// @gate skipUnmountedBoundaries
27022524
it('should rethrow error if there are no still-mounted boundaries', () => {
27032525
function Conditional({showChildren}) {
27042526
if (showChildren) {

packages/react/src/__tests__/ReactDOMTracing-test.internal.js

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -152,16 +152,7 @@ describe('ReactDOMTracing', () => {
152152
onInteractionScheduledWorkCompleted,
153153
).toHaveBeenLastNotifiedOfInteraction(interaction);
154154

155-
if (gate(flags => flags.new)) {
156-
expect(onRender).toHaveBeenCalledTimes(3);
157-
} else {
158-
// TODO: This is 4 instead of 3 because this update was scheduled at
159-
// idle priority, and idle updates are slightly higher priority than
160-
// offscreen work. So it takes two render passes to finish it. Profiler
161-
// calls `onRender` for the first render even though everything
162-
// bails out.
163-
expect(onRender).toHaveBeenCalledTimes(4);
164-
}
155+
expect(onRender).toHaveBeenCalledTimes(3);
165156
expect(onRender).toHaveLastRenderedWithInteractions(
166157
new Set([interaction]),
167158
);
@@ -310,16 +301,7 @@ describe('ReactDOMTracing', () => {
310301
expect(
311302
onInteractionScheduledWorkCompleted,
312303
).toHaveBeenLastNotifiedOfInteraction(interaction);
313-
if (gate(flags => flags.new)) {
314-
expect(onRender).toHaveBeenCalledTimes(3);
315-
} else {
316-
// TODO: This is 4 instead of 3 because this update was scheduled at
317-
// idle priority, and idle updates are slightly higher priority than
318-
// offscreen work. So it takes two render passes to finish it. Profiler
319-
// calls `onRender` for the first render even though everything
320-
// bails out.
321-
expect(onRender).toHaveBeenCalledTimes(4);
322-
}
304+
expect(onRender).toHaveBeenCalledTimes(3);
323305
expect(onRender).toHaveLastRenderedWithInteractions(
324306
new Set([interaction]),
325307
);

packages/react/src/__tests__/ReactProfiler-test.internal.js

Lines changed: 9 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ describe('Profiler', () => {
347347

348348
expect(callback).toHaveBeenCalledTimes(1);
349349

350-
let call = callback.mock.calls[0];
350+
const call = callback.mock.calls[0];
351351

352352
expect(call).toHaveLength(enableSchedulerTracing ? 7 : 6);
353353
expect(call[0]).toBe('test');
@@ -364,31 +364,9 @@ describe('Profiler', () => {
364364

365365
renderer.update(<App />);
366366

367-
if (gate(flags => flags.new)) {
368-
// None of the Profiler's subtree was rendered because App bailed out before the Profiler.
369-
// So we expect onRender not to be called.
370-
expect(callback).not.toHaveBeenCalled();
371-
} else {
372-
// Updating a parent reports a re-render,
373-
// since React technically did a little bit of work between the Profiler and the bailed out subtree.
374-
// This is not optimal but it's how the old reconciler fork works.
375-
expect(callback).toHaveBeenCalledTimes(1);
376-
377-
call = callback.mock.calls[0];
378-
379-
expect(call).toHaveLength(enableSchedulerTracing ? 7 : 6);
380-
expect(call[0]).toBe('test');
381-
expect(call[1]).toBe('update');
382-
expect(call[2]).toBe(0); // actual time
383-
expect(call[3]).toBe(10); // base time
384-
expect(call[4]).toBe(30); // start time
385-
expect(call[5]).toBe(30); // commit time
386-
expect(call[6]).toEqual(
387-
enableSchedulerTracing ? new Set() : undefined,
388-
); // interaction events
389-
390-
callback.mockReset();
391-
}
367+
// None of the Profiler's subtree was rendered because App bailed out before the Profiler.
368+
// So we expect onRender not to be called.
369+
expect(callback).not.toHaveBeenCalled();
392370

393371
Scheduler.unstable_advanceTime(20); // 30 -> 50
394372

@@ -3714,15 +3692,11 @@ describe('Profiler', () => {
37143692
wrappedCascadingFn();
37153693
expect(Scheduler).toHaveYielded(['onPostCommit', 'render']);
37163694

3717-
// The new reconciler does not call onPostCommit again
3718-
// because the resolved suspended subtree doesn't contain any passive effects.
3719-
// If <AsyncComponentWithCascadingWork> or its decendents had a passive effect,
3720-
// onPostCommit would be called again.
3721-
if (gate(flags => flags.new)) {
3722-
expect(Scheduler).toFlushAndYield([]);
3723-
} else {
3724-
expect(Scheduler).toFlushAndYield(['onPostCommit']);
3725-
}
3695+
// Does not call onPostCommit again because the resolved suspended
3696+
// subtree doesn't contain any passive effects. If
3697+
// <AsyncComponentWithCascadingWork> or its decendents had a passive
3698+
// effect, onPostCommit would be called again.
3699+
expect(Scheduler).toFlushAndYield([]);
37263700

37273701
expect(onInteractionScheduledWorkCompleted).toHaveBeenCalledTimes(1);
37283702
expect(
@@ -4209,7 +4183,6 @@ describe('Profiler', () => {
42094183
});
42104184

42114185
if (__DEV__) {
4212-
// @gate new
42134186
it('double invoking does not disconnect wrapped async work', () => {
42144187
ReactFeatureFlags.enableDoubleInvokingEffects = true;
42154188

0 commit comments

Comments
 (0)