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

Use depth (not owner) to check for root components #558

Merged
merged 1 commit into from
Dec 5, 2013

Conversation

sophiebits
Copy link
Collaborator

Fixes #557.

@vjeux
Copy link
Contributor

vjeux commented Nov 18, 2013

That makes sense to me, but I haven't enough experience in this part of the code base. cc @yungsters, @petehunt

@ghost ghost assigned yungsters Nov 18, 2013
@yungsters
Copy link
Contributor

I don't think this is the right fix, but I don't have an alternate suggestion. Hmm...

@sophiebits
Copy link
Collaborator Author

Why isn't this right?

@petehunt
Copy link
Contributor

Isn't this a bug? I think owner isn't getting set correctly (it should be null if created outside of React, right?)

@sophiebits
Copy link
Collaborator Author

Well, if you had specified a ref on the auxiliary component

<Tooltip ref="tooltip" tooltip={<div ref="tip">{this.props.tooltipText}</div>}>
  {this.props.text}
</Tooltip>

then you'd still want the tooltip and tip refs to be attached to the same component, so I decided that __owner__ is correct as-is.

@sophiebits
Copy link
Collaborator Author

If it helps, note that mountDepth === 0 only if the component was rendered with mountComponentIntoNode which is called only by ReactMount._renderNewRootComponent.

@yungsters
Copy link
Contributor

Thanks for taking the time to explain. This looks reasonable to me.

// Even though this.props.tooltip has an owner, updating it shouldn't
// throw here because it's mounted as a root component
React.renderComponent(this.props.tooltip, this.container);
},
Copy link
Member

Choose a reason for hiding this comment

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

nit: extra comma that our lint complains about (need to figure out linting these tests...)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Inconvenient __owner__ assignment prevents updating a component
5 participants