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 — update hideOrUnhideAllChildren to hide portals that aren't wrapped in… · react/react@de2edc2

File tree

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

‎packages/react-dom/src/__tests__/ReactDOMSuspensePlaceholder-test.js‎

Copy file name to clipboardExpand all lines: packages/react-dom/src/__tests__/ReactDOMSuspensePlaceholder-test.js
+23Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,29 @@ describe('ReactDOMSuspensePlaceholder', () => {
104104
expect(window.getComputedStyle(divs[2].current).display).toEqual('inline');
105105
});
106106

107+
it('hides and unhides child portals', async () => {
108+
const portalContainer = document.createElement('div');
109+
function Component() {
110+
return ReactDOM.createPortal(<span />, portalContainer);
111+
}
112+
113+
function App() {
114+
return (
115+
<Suspense fallback={<Text text="Loading..." />}>
116+
<AsyncText ms={500} text="A" />
117+
<Component />
118+
</Suspense>
119+
);
120+
}
121+
122+
ReactDOM.render(<App />, container);
123+
expect(window.getComputedStyle(portalContainer).display).toEqual('none');
124+
125+
await advanceTimers(500);
126+
Scheduler.unstable_flushAll();
127+
expect(window.getComputedStyle(portalContainer).display).toEqual('block');
128+
});
129+
107130
it('hides and unhides timed out text nodes', async () => {
108131
function App() {
109132
return (
Collapse file

‎packages/react-reconciler/src/ReactFiberCommitWork.js‎

Copy file name to clipboardExpand all lines: packages/react-reconciler/src/ReactFiberCommitWork.js
+7Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -645,6 +645,13 @@ function hideOrUnhideAllChildren(finishedWork, isHidden) {
645645
} else {
646646
unhideInstance(node.stateNode, node.memoizedProps);
647647
}
648+
} else if (node.tag === HostPortal) {
649+
const instance = node.stateNode.containerInfo;
650+
if (isHidden) {
651+
hideInstance(instance);
652+
} else {
653+
unhideInstance(instance, node.memoizedProps);
654+
}
648655
} else if (node.tag === HostText) {
649656
const instance = node.stateNode;
650657
if (isHidden) {

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.