Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support inner component _debugOwner in memo #18659

Closed
wants to merge 3 commits into from

Conversation

hanq08
Copy link
Contributor

@hanq08 hanq08 commented Apr 17, 2020

Summary

Add _debugOwner to inner component of memo.
#18571

Test Plan

one test added. Not familiar with the react test tool. let me know if it's good thanks.

@facebook-github-bot
Copy link

Hi @hanq08!

Thank you for your pull request and welcome to our community.We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file.

In order for us to review and merge your code, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

If you have received this in error or have any questions, please contact us at [email protected]. Thanks!

@codesandbox-ci
Copy link

codesandbox-ci bot commented Apr 17, 2020

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 51a00f0:

Sandbox Source
happy-silence-1eef1 Configuration

@sizebot
Copy link

sizebot commented Apr 17, 2020

No significant bundle size changes to report.

Size changes (experimental)

Generated by 🚫 dangerJS against 51a00f0

@sizebot
Copy link

sizebot commented Apr 17, 2020

No significant bundle size changes to report.

Size changes (stable)

Generated by 🚫 dangerJS against 51a00f0

@facebook-github-bot
Copy link

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks!

@hanq08 hanq08 requested review from aweary and gaearon April 18, 2020 04:18
@hanq08
Copy link
Contributor Author

hanq08 commented Apr 22, 2020

@aweary @gaearon could you have a look at this when available thanks

@bvaughn bvaughn self-assigned this Jul 18, 2020
},
]
`;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This snapshot is out of date now. (Not your fault.) Rebasing on master would result in a snapshot delta of:

diff --git a/packages/react-devtools-shared/src/__tests__/__snapshots__/ownersListContext-test.js.snap b/packages/react-devtools-shared/src/__tests__/__snapshots__/ownersListContext-test.js.snap
index 7ef006fda..9b7609788 100644
--- a/packages/react-devtools-shared/src/__tests__/__snapshots__/ownersListContext-test.js.snap
+++ b/packages/react-devtools-shared/src/__tests__/__snapshots__/ownersListContext-test.js.snap
@@ -88,13 +88,17 @@ Array [
   },
   Object {
     "displayName": "Anonymous",
-    "hocDisplayNames": null,
+    "hocDisplayNames": Array [
+      "Memo",
+    ],
     "id": 3,
     "type": 8,
   },
   Object {
     "displayName": "Anonymous",
-    "hocDisplayNames": null,
+    "hocDisplayNames": Array [
+      "ForwardRef",
+    ],
     "id": 4,
     "type": 6,
   },

@@ -206,4 +206,42 @@ describe('OwnersListContext', () => {

done();
});

it('should include all owners for a component wrapped in react memo ', async done => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:

Suggested change
it('should include all owners for a component wrapped in react memo ', async done => {
it('should include all owners for a component wrapped in react memo', async done => {

Comment on lines +211 to +216
const InnerComponent = React.forwardRef((props, ref) => <div ref={ref} />);
const Memo = React.memo(InnerComponent);
const Grandparent = () => {
const ref = React.createRef();
return <Memo ref={ref} />;
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit Let's use a named function so we don't see "Anonymous" in the tests?

Suggested change
const InnerComponent = React.forwardRef((props, ref) => <div ref={ref} />);
const Memo = React.memo(InnerComponent);
const Grandparent = () => {
const ref = React.createRef();
return <Memo ref={ref} />;
};
const InnerComponent = (props, ref) => <div ref={ref} />;
const ForwardRef = React.forwardRef(InnerComponent);
const Memo = React.memo(ForwardRef);
const Grandparent = () => {
const ref = React.createRef();
return <Memo ref={ref} />;
};

@bvaughn
Copy link
Contributor

bvaughn commented Aug 7, 2020

I removed my previous comment because it seems to have been in error. Digging in more.

@bvaughn
Copy link
Contributor

bvaughn commented Aug 7, 2020

Moving things over to #19556 since I can't push to the branch this is based off of. Will land there.

@bvaughn bvaughn closed this Aug 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants