Skip to content

Fix this in a functional component for ShallowRenderer #13144

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Conversation

koba04
Copy link
Contributor

@koba04 koba04 commented Jul 3, 2018

Fixes #13141

@gaearon gaearon merged commit c039c16 into facebook:master Jul 3, 2018
@gaearon
Copy link
Collaborator

gaearon commented Jul 3, 2018

Thanks!

@ljharb
Copy link
Contributor

ljharb commented Jul 3, 2018

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

@gaearon
Copy link
Collaborator

gaearon commented Jul 3, 2018

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

@ljharb
Copy link
Contributor

ljharb commented Jul 3, 2018

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

@gaearon
Copy link
Collaborator

gaearon commented Jul 3, 2018

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

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

works.

@ljharb
Copy link
Contributor

ljharb commented Jul 3, 2018

aha, thanks

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

koba04 commented Jul 4, 2018

Thanks!

@gaearon gaearon mentioned this pull request Sep 5, 2018
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants