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

Elements from functional components in TestUtils should have no owner #6362

Merged
merged 1 commit into from
Apr 14, 2016
Merged

Elements from functional components in TestUtils should have no owner #6362

merged 1 commit into from
Apr 14, 2016

Conversation

gaearon
Copy link
Collaborator

@gaearon gaearon commented Mar 28, 2016

Another take at fixing #5292 and #6194. We’ll fix it more permanently later once we completely remove the owner but it is still currently useful for warnings and ReactPerf.

Reviewers: @sebmarkbage

@@ -61,6 +61,10 @@ function warnIfInvalidElement(Component, element) {
}
}

function isNewable(Component) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe this should be called "shouldConstruct" or something like that? Functional components can be "newable" in the ECMAScript sense but shouldn't be called with new.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

shouldConstruct sounds good. A little misleading that we still call _constructComponent even though shouldConstruct can be false but I’m out of good function names at this point. (instantiate* is taken for another purpose 😄 )

@sebmarkbage
Copy link
Collaborator

EDIT: nvm. I misread.

cc @spicyj You have a lot more context on this.

@gaearon
Copy link
Collaborator Author

gaearon commented Mar 28, 2016

Sure, I’m fine holding it off till 15.0.1 or something along with #6353.
I’ll create a milestone.

@gaearon gaearon added this to the 15.x milestone Mar 28, 2016
@facebook-github-bot
Copy link

@gaearon updated the pull request.

@sophiebits
Copy link
Collaborator

I looked but don't know what is best here without spending a lot more time thinking.

@gaearon
Copy link
Collaborator Author

gaearon commented Mar 28, 2016

What are the bad implications of this? Sure it’s a hack, but it’s pretty much identical to how we fix the same case for render().

@sophiebits
Copy link
Collaborator

I didn't realize we did that for render already. Sure, this seems okay.

@gaearon
Copy link
Collaborator Author

gaearon commented Mar 31, 2016

Yeah. Owner is a goner anyway so I think we should be able to remove these hacks before 16.

@sophiebits
Copy link
Collaborator

Well, owner is sticking around as long as we support string refs unless I missed something.

@gaearon
Copy link
Collaborator Author

gaearon commented Mar 31, 2016

Can we deprecate them during 15.x?

@sophiebits
Copy link
Collaborator

We haven't thought it's worth it because the new API is significantly less convenient.

@sophiebits
Copy link
Collaborator

We can always consider it, though.

@sebmarkbage
Copy link
Collaborator

I generally don't think we should deprecate things unless we're willing or have already done the work internally at FB. (I don't think we are yet. The trade off isn't worth the work.) We use ourselves as a proxy. I don't want to tell others to do work that we're not willing to do ourselves.

@gaearon gaearon modified the milestones: 15.x, 15.0.x Apr 14, 2016
@gaearon gaearon merged commit ae56910 into facebook:master Apr 14, 2016
@gaearon gaearon deleted the no-owner-in-test-utils branch April 14, 2016 17:54
@gaearon
Copy link
Collaborator Author

gaearon commented Apr 14, 2016

I’m getting this in since it fixes a bug and the workaround is on par with a similar workaround we’re already using. We have a test too so we won’t regress until this is fixed in a better way.

zpao pushed a commit that referenced this pull request Apr 28, 2016
Elements from functional components in TestUtils should have no owner
(cherry picked from commit ae56910)
@zpao zpao modified the milestones: 15.0.2, 15.0.x Apr 28, 2016
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