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

Fix this in a functional component for ShallowRenderer #13144

Conversation

@koba04
Copy link
Contributor

@koba04 koba04 commented Jul 3, 2018

Fixes #13141

ljharb
ljharb approved these changes Jul 3, 2018
gaearon
gaearon approved these changes Jul 3, 2018
@gaearon gaearon merged commit c039c16 into facebook:master Jul 3, 2018
1 check passed
Loading
@gaearon
Copy link
Member

@gaearon gaearon commented Jul 3, 2018

Thanks!

Loading

@ljharb
Copy link
Contributor

@ljharb ljharb commented Jul 3, 2018

So actually I think this will break createReactClass components, because they don't have .isReactComponent :-/

Loading

@gaearon
Copy link
Member

@gaearon gaearon commented Jul 3, 2018

They assign ReactComponent.prototype (where ReactComponent is React.Component) which includes it. Without this flag, we never new something.

Loading

@ljharb
Copy link
Contributor

@ljharb ljharb commented Jul 3, 2018

hmm - when i createReactClass({ render() {} }).isReactComponent i get undefined. What am i missing?

Loading

@gaearon
Copy link
Member

@gaearon gaearon commented Jul 3, 2018

It's on the prototype, not on the class.

createReactClass({ render() {} }).prototype.isReactComponent

works.

Loading

@ljharb
Copy link
Contributor

@ljharb ljharb commented Jul 3, 2018

aha, thanks

Loading

@koba04 koba04 deleted the fix-this-in-functional-component-on-shallow-renderer branch Jul 4, 2018
@koba04
Copy link
Contributor Author

@koba04 koba04 commented Jul 4, 2018

Thanks!

Loading

@gaearon gaearon mentioned this pull request Sep 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants