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 — Support inner component _debugOwner in memo (#19556) · react/react@0c52e24

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • packages
    • react-devtools-shared/src/__tests__
      • __snapshots__
        • ownersListContext-test.js.snap
      • ownersListContext-test.js
    • react-reconciler/src
      • ReactFiber.new.js
      • ReactFiber.old.js
      • ReactFiberBeginWork.new.js
      • ReactFiberBeginWork.old.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎packages/react-devtools-shared/src/__tests__/__snapshots__/ownersListContext-test.js.snap‎

Copy file name to clipboardExpand all lines: packages/react-devtools-shared/src/__tests__/__snapshots__/ownersListContext-test.js.snap
+27Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,33 @@ Array [
7878
]
7979
`;
8080
81+
exports[`OwnersListContext should include all owners for a component wrapped in react memo: owners for "InnerComponent" 1`] = `
82+
Array [
83+
Object {
84+
"displayName": "Grandparent",
85+
"hocDisplayNames": null,
86+
"id": 2,
87+
"type": 5,
88+
},
89+
Object {
90+
"displayName": "InnerComponent",
91+
"hocDisplayNames": Array [
92+
"Memo",
93+
],
94+
"id": 3,
95+
"type": 8,
96+
},
97+
Object {
98+
"displayName": "InnerComponent",
99+
"hocDisplayNames": Array [
100+
"ForwardRef",
101+
],
102+
"id": 4,
103+
"type": 6,
104+
},
105+
]
106+
`;
107+
81108
exports[`OwnersListContext should include the current element even if there are no other owners: mount 1`] = `
82109
[root]
83110
<Grandparent>
Collapse file

‎packages/react-devtools-shared/src/__tests__/ownersListContext-test.js‎

Copy file name to clipboardExpand all lines: packages/react-devtools-shared/src/__tests__/ownersListContext-test.js
+39Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,4 +206,43 @@ describe('OwnersListContext', () => {
206206

207207
done();
208208
});
209+
210+
it('should include all owners for a component wrapped in react memo', async done => {
211+
const InnerComponent = (props, ref) => <div ref={ref} />;
212+
const ForwardRef = React.forwardRef(InnerComponent);
213+
const Memo = React.memo(ForwardRef);
214+
const Grandparent = () => {
215+
const ref = React.createRef();
216+
return <Memo ref={ref} />;
217+
};
218+
219+
utils.act(() =>
220+
ReactDOM.render(<Grandparent />, document.createElement('div')),
221+
);
222+
223+
let didFinish = false;
224+
function Suspender({owner}) {
225+
const read = React.useContext(OwnersListContext);
226+
const owners = read(owner.id);
227+
didFinish = true;
228+
expect(owners.length).toBe(3);
229+
expect(owners).toMatchSnapshot(
230+
`owners for "${(owner && owner.displayName) || ''}"`,
231+
);
232+
return null;
233+
}
234+
235+
const wrapped = ((store.getElementAtIndex(2): any): Element);
236+
await utils.actAsync(() =>
237+
TestRenderer.create(
238+
<Contexts defaultOwnerID={wrapped.id}>
239+
<React.Suspense fallback={null}>
240+
<Suspender owner={wrapped} />
241+
</React.Suspense>
242+
</Contexts>,
243+
),
244+
);
245+
expect(didFinish).toBe(true);
246+
done();
247+
});
209248
});
Collapse file

‎packages/react-reconciler/src/ReactFiber.new.js‎

Copy file name to clipboardExpand all lines: packages/react-reconciler/src/ReactFiber.new.js
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,10 @@ export function createFiberFromTypeAndProps(
579579
fiber.type = resolvedType;
580580
fiber.lanes = lanes;
581581

582+
if (__DEV__) {
583+
fiber._debugOwner = owner;
584+
}
585+
582586
return fiber;
583587
}
584588

Collapse file

‎packages/react-reconciler/src/ReactFiber.old.js‎

Copy file name to clipboardExpand all lines: packages/react-reconciler/src/ReactFiber.old.js
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,10 @@ export function createFiberFromTypeAndProps(
573573
fiber.type = resolvedType;
574574
fiber.lanes = lanes;
575575

576+
if (__DEV__) {
577+
fiber._debugOwner = owner;
578+
}
579+
576580
return fiber;
577581
}
578582

Collapse file

‎packages/react-reconciler/src/ReactFiberBeginWork.new.js‎

Copy file name to clipboardExpand all lines: packages/react-reconciler/src/ReactFiberBeginWork.new.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ function updateMemoComponent(
434434
Component.type,
435435
null,
436436
nextProps,
437-
null,
437+
workInProgress,
438438
workInProgress.mode,
439439
renderLanes,
440440
);
Collapse file

‎packages/react-reconciler/src/ReactFiberBeginWork.old.js‎

Copy file name to clipboardExpand all lines: packages/react-reconciler/src/ReactFiberBeginWork.old.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ function updateMemoComponent(
434434
Component.type,
435435
null,
436436
nextProps,
437-
null,
437+
workInProgress,
438438
workInProgress.mode,
439439
renderLanes,
440440
);

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.