-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Stateless functional components have "this" defined #1683
Comments
It might just be "This is how javascript works" with functions and this, but it was a shock to me because we refactored a few classes into stateless functions and had one break because we missed the this.props but the tests were still passing. Functional components shouldn't have this.props defined, so i think its enzyme's shallow stuff. |
Hmm, that does seem like an issue - |
This is a bug in |
ok, confirmed it's only a bug in shallow, and only in react 16. |
Describe the bug
Looks like stateless functional components work differently in browser vs enzyme.
I'm not sure if this is a enzyme, react, react-test-utils or babel issue.
To Reproduce
Run this jest test
Expected behavior
Both tests should fail (not sure how to properly write that, maybe expect throws?) but only the arrow function has this as undefined.
Module Versions:
Node Verison: v8.11.3
LSB Version: :core-4.1-amd64:core-4.1-noarch
Distributor ID: CentOS
Description: CentOS Linux release 7.5.1804 (Core)
Release: 7.5.1804
Codename: Core
The text was updated successfully, but these errors were encountered: