-
Notifications
You must be signed in to change notification settings - Fork 51k
Reorganize how shared internals are accessed #13201
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| /** | ||
| * Copyright (c) 2013-present, Facebook, Inc. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| */ | ||
|
|
||
| import assign from 'object-assign'; | ||
| import ReactCurrentOwner from './ReactCurrentOwner'; | ||
| import ReactDebugCurrentFrame from './ReactDebugCurrentFrame'; | ||
|
|
||
| const ReactSharedInternals = { | ||
| ReactCurrentOwner, | ||
| // Used by renderers to avoid bundling object-assign twice in UMD bundles: | ||
| assign, | ||
| }; | ||
|
|
||
| if (__DEV__) { | ||
| Object.assign(ReactSharedInternals, { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know this code was just moved, but I'm curious why assign is imported above, but Object.assign is used here. Are they equivalent?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We could put
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In other words:
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I didn't realize Object.assign compiled down to the
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hm, it's early so maybe Dan's explanation makes sense– but after reading it twice, I'm still confused about why we import import assign from 'object-assign';But then use Edit: I just spotted the
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
We could, I just didn't see the point in explicitly using it in a situation where we normally wouldn't.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In other words — they're the same thing. The intention of the code is "put this Node module onto an object". So I'm using
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That...makes sense, but I still find the distinction (within this file) confusing. And I suspect others might too. 😄
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Open to other suggestions, I don’t really care either way. Feel free to change it to what’s looks less confusing. This isn’t new code.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not really sure what's better, and I can go either way. I don't consider it a blocker for getting this change in. |
||
| // These should not be included in production. | ||
| ReactDebugCurrentFrame, | ||
| // Shim for React DOM 16.0.0 which still destructured (but not used) this. | ||
| // TODO: remove in React 17.0. | ||
| ReactComponentTreeHook: {}, | ||
| }); | ||
| } | ||
|
|
||
| export default ReactSharedInternals; | ||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| /** | ||
| * Copyright (c) 2013-present, Facebook, Inc. | ||
| * | ||
| * This source code is licensed under the MIT license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| */ | ||
|
|
||
| import React from 'react'; | ||
|
|
||
| const ReactSharedInternals = | ||
| React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; | ||
|
|
||
| export default ReactSharedInternals; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It doesn't exist outside of DEV, which is true in other "hook" files too. Other "hook" files don't have DEV blocks (they just assume they're called only in DEV) so I didn't put the condition there. Since this file already had a condition, I put it conditionally.