GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Regression test: Missing unmount after re-order (#20285) · react/react@0f83a64

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • packages/react-reconciler/src/__tests__
    • ReactHooksWithNoopRenderer-test.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

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

Copy file name to clipboardExpand all lines: packages/react-reconciler/src/__tests__/ReactHooksWithNoopRenderer-test.js
+46Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3370,4 +3370,50 @@ describe('ReactHooksWithNoopRenderer', () => {
33703370
});
33713371
expect(Scheduler).toHaveYielded(['Unmount layout B', 'Unmount passive B']);
33723372
});
3373+
3374+
it('regression: deleting a tree and unmounting its effects after a reorder', async () => {
3375+
const root = ReactNoop.createRoot();
3376+
3377+
function Child({label}) {
3378+
useEffect(() => {
3379+
Scheduler.unstable_yieldValue('Mount ' + label);
3380+
return () => {
3381+
Scheduler.unstable_yieldValue('Unmount ' + label);
3382+
};
3383+
}, [label]);
3384+
return label;
3385+
}
3386+
3387+
await act(async () => {
3388+
root.render(
3389+
<>
3390+
<Child key="A" label="A" />
3391+
<Child key="B" label="B" />
3392+
</>,
3393+
);
3394+
});
3395+
expect(Scheduler).toHaveYielded(['Mount A', 'Mount B']);
3396+
3397+
await act(async () => {
3398+
root.render(
3399+
<>
3400+
<Child key="B" label="B" />
3401+
<Child key="A" label="A" />
3402+
</>,
3403+
);
3404+
});
3405+
expect(Scheduler).toHaveYielded([]);
3406+
3407+
await act(async () => {
3408+
root.render(null);
3409+
});
3410+
3411+
expect(Scheduler).toHaveYielded([
3412+
'Unmount B',
3413+
// In the regression, the reorder would cause Child A to "forget" that it
3414+
// contains passive effects. Then when we deleted the tree, A's unmount
3415+
// effect would not fire.
3416+
'Unmount A',
3417+
]);
3418+
});
33733419
});

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.