mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
* Failing test for #18657 * Remove incorrect priority check I think this was just poor factoring on my part in #18411. Honestly it doesn't make much sense to me, but my best guess is that I must have thought that when `baseTime > currentChildExpirationTime`, the function would fall through to the `currentChildExpirationTime < renderExpirationTime` branch below. Really I think just made an oopsie. Regardless, this logic is galaxy brainéd. A goal of the Lanes refactor I'm working on is to make these types of checks -- is there remaining work in this tree? -- a lot easier to think about. Hopefully.
This commit is contained in:
@@ -1681,11 +1681,7 @@ function getRemainingWorkInPrimaryTree(
|
||||
// This boundary already timed out. Check if this render includes the level
|
||||
// that previously suspended.
|
||||
const baseTime = currentSuspenseState.baseTime;
|
||||
if (
|
||||
baseTime !== NoWork &&
|
||||
baseTime < renderExpirationTime &&
|
||||
baseTime > currentChildExpirationTime
|
||||
) {
|
||||
if (baseTime !== NoWork && baseTime < renderExpirationTime) {
|
||||
// There's pending work at a lower level that might now be unblocked.
|
||||
return baseTime;
|
||||
}
|
||||
|
||||
@@ -1681,11 +1681,7 @@ function getRemainingWorkInPrimaryTree(
|
||||
// This boundary already timed out. Check if this render includes the level
|
||||
// that previously suspended.
|
||||
const baseTime = currentSuspenseState.baseTime;
|
||||
if (
|
||||
baseTime !== NoWork &&
|
||||
baseTime < renderExpirationTime &&
|
||||
baseTime > currentChildExpirationTime
|
||||
) {
|
||||
if (baseTime !== NoWork && baseTime < renderExpirationTime) {
|
||||
// There's pending work at a lower level that might now be unblocked.
|
||||
return baseTime;
|
||||
}
|
||||
|
||||
+49
@@ -3869,4 +3869,53 @@ describe('ReactSuspenseWithNoopRenderer', () => {
|
||||
expect(root).toMatchRenderedOutput(<span prop="b" />);
|
||||
});
|
||||
});
|
||||
|
||||
it('regression: #18657', async () => {
|
||||
const {useState} = React;
|
||||
|
||||
let setText;
|
||||
function App() {
|
||||
const [text, _setText] = useState('A');
|
||||
setText = _setText;
|
||||
return <AsyncText text={text} />;
|
||||
}
|
||||
|
||||
const root = ReactNoop.createRoot();
|
||||
await ReactNoop.act(async () => {
|
||||
await resolveText('A');
|
||||
root.render(
|
||||
<Suspense fallback={<Text text="Loading..." />}>
|
||||
<App />
|
||||
</Suspense>,
|
||||
);
|
||||
});
|
||||
expect(Scheduler).toHaveYielded(['A']);
|
||||
expect(root).toMatchRenderedOutput(<span prop="A" />);
|
||||
|
||||
await ReactNoop.act(async () => {
|
||||
setText('B');
|
||||
Scheduler.unstable_runWithPriority(
|
||||
Scheduler.unstable_IdlePriority,
|
||||
() => {
|
||||
setText('B');
|
||||
},
|
||||
);
|
||||
// Suspend the first update. The second update doesn't run because it has
|
||||
// Idle priority.
|
||||
expect(Scheduler).toFlushAndYield(['Suspend! [B]', 'Loading...']);
|
||||
|
||||
// Commit the fallback. Now we'll try working on Idle.
|
||||
jest.runAllTimers();
|
||||
|
||||
// It also suspends.
|
||||
expect(Scheduler).toFlushAndYield(['Suspend! [B]']);
|
||||
});
|
||||
|
||||
await ReactNoop.act(async () => {
|
||||
setText('B');
|
||||
await resolveText('B');
|
||||
});
|
||||
expect(Scheduler).toHaveYielded(['Promise resolved [B]', 'B']);
|
||||
expect(root).toMatchRenderedOutput(<span prop="B" />);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user