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

refactor: remove unnecessary judgment when check fragment props #13566

Conversation

gebilaoxiong
Copy link
Contributor

@gebilaoxiong gebilaoxiong commented Sep 5, 2018

There is a small problem with the judgment here.

When we define key in props we use the descriptor like this

  Object.defineProperty(props, 'key', {
    get: warnAboutAccessingKey,
    configurable: true,
  });

When enumerable is not defined, the default value is false.
doc: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/defineProperty

So when we use Object.keys to get the fragement props, we will never get the key.
code: https://github.com/facebook/react/blob/master/packages/react/src/ReactElementValidator.js#L239

@pull-bot
Copy link

pull-bot commented Sep 5, 2018

Details of bundled changes.

Comparing: 9a110eb...91a971b

schedule

File Filesize Diff Gzip Diff Prev Size Current Size Prev Gzip Current Gzip ENV
schedule.development.js n/a n/a 0 B 19.17 KB 0 B 5.74 KB UMD_DEV
schedule.production.min.js n/a n/a 0 B 3.16 KB 0 B 1.53 KB UMD_PROD

Generated by 🚫 dangerJS

@gaearon
Copy link
Collaborator

gaearon commented Sep 5, 2018

What's the point of specifying the default value explicitly?

@gebilaoxiong
Copy link
Contributor Author

gebilaoxiong commented Sep 5, 2018

@gaearon

If we continue to use Object.keys later
We can intuitively find there is no need to judge key and ref..

If it is not necessary, I can remove it.

@stale
Copy link

stale bot commented Jan 10, 2020

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contribution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed Resolution: Stale Automatically closed due to inactivity
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants