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

Warn when nesting 15 subtree inside 16 #10434

Merged
merged 1 commit into from
Aug 13, 2017

Conversation

sophiebits
Copy link
Collaborator

No description provided.

'a React 15 tree inside a React 16 tree using ' +
"unstable_renderSubtreeIntoContainer, which isn't supported. Try to " +
'make sure you have only one copy of React (and ideally, switch to ' +
'React.unstable_createPortal).',
Copy link
Collaborator

Choose a reason for hiding this comment

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

It's currently on ReactDOM.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oh weird. Why? Can amend if that's really intentional.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Intentional because it accepts a DOM node as an argument. Could make one shared around DOM client renderers or SSR compatible that accepts a different argument such as a string query.

@sebmarkbage
Copy link
Collaborator

Did changing the name of _reactInternalInstance not work out?

@sophiebits
Copy link
Collaborator Author

I think we still need a fake _processChildContext method – you'd prefer changing the name _reactInternalInstance and adding a field ._reactInternalInstance = {_processChildContext: throw} on class components?

@sebmarkbage
Copy link
Collaborator

Yea, I'd prefer that. The possibilities of collision here seems scary.

What happens if we don't add the place holder to class instances?

@sophiebits
Copy link
Collaborator Author

I'm not sure what your last question means.

Copy link
Collaborator Author

@sophiebits sophiebits left a comment

Choose a reason for hiding this comment

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

Better?

@@ -283,6 +305,7 @@ module.exports = function(
workInProgress.stateNode = instance;
// The instance needs access to the fiber so that it can schedule updates
ReactInstanceMap.set(instance, workInProgress);
instance._reactInternalInstance = fakeInternalInstance;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Should I make this DEV-only? Seems safer to have it be in prod too. :(

Copy link
Collaborator

Choose a reason for hiding this comment

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

DEV only plz. We stick random stuff on classes all over.

Copy link
Collaborator

Choose a reason for hiding this comment

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

If it's DEV only we at least know that we can remove it at some point. E.g. a minor.

@@ -26,19 +26,19 @@ var ReactInstanceMap = {
* supported we can rename it.
*/
remove: function(key) {
key._reactInternalInstance = undefined;
key._reactInternalInstance16 = undefined;
Copy link
Collaborator

Choose a reason for hiding this comment

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

_reactInternalFiber?

@sebmarkbage
Copy link
Collaborator

Does this just work with devtools?

'a React 15 tree inside a React 16 tree using ' +
"unstable_renderSubtreeIntoContainer, which isn't supported. Try " +
'to make sure you have only one copy of React (and ideally, switch ' +
'to ReactDOM.unstable_createPortal).',
Copy link
Contributor

Choose a reason for hiding this comment

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

nit - we could condense this and then link to docs, which could provide more info.

I think we could always improve the error message in a follow-up commit, if this comes up often for folks.

@flarnie
Copy link
Contributor

flarnie commented Aug 13, 2017

Does this just work with devtools?

I'm not sure what that was referring to - it seems like this would work in DEV mode.

lgtm but want to let @sebmarkbage give it a final look if possible.

@sophiebits
Copy link
Collaborator Author

sophiebits commented Aug 13, 2017 via email

@flarnie
Copy link
Contributor

flarnie commented Aug 13, 2017

Sounds good - I'll do a quick manual test.

Copy link
Contributor

@flarnie flarnie left a comment

Choose a reason for hiding this comment

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

I checked out this branch and looked at the dom fixtures with the React devtools, everything works.

@sophiebits sophiebits merged commit 9921e57 into facebook:master Aug 13, 2017
@@ -26,19 +26,19 @@ var ReactInstanceMap = {
* supported we can rename it.
*/
remove: function(key) {
key._reactInternalInstance = undefined;
key._reactInternalFiber = undefined;
Copy link
Collaborator

Choose a reason for hiding this comment

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

This will break hot reloading (which we just fixed). Do you mind sending a PR to react-deep-force-update to account for this change? Should be as easy as checking both fields.

@bvaughn bvaughn mentioned this pull request Sep 7, 2017
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.

5 participants