-
-
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
State is always initialized under shallow
#1849
Comments
shallow
See https://jsfiddle.net/69z2wepo/310645/ - it looks like I've added some tests that verify this, which seem to be passing locally. Can you try updating to the latest enzyme (v3.6.0)? |
I will upgrade and see. |
Very true; it looks like actually in React 16.0 - 16.3 this might be the case (please fill out the entire issue template). What React version are you using? |
Turns out this is a bug in the React shallow renderer, fixed in facebook/react#11965. I'll see if I can fix it in the 16.0, 16.1, and 16.2 adapters. |
@ljharb Thanks for the quick turnaround Just to close the loop, when will the fix appear in the adapter packages? |
The next release will include it; hopefully it will be in the next couple days. |
@ljharb Thanks! Appreciate the quick response |
- [new] add `isCustomComponentElement` (#1832) - [fix] (<= v16.2) ensure that `this.state` starts out `null` when unspecified on a custom component (#1849) - [fix] `forwardRef`: respect `.displayName` on the forwardRef (#1817) - [deps] update `babel-preset-airbnb`, `chai`, `eslint`, `mocha`, `enzyme-adapter-utils`, `react-is`, `airbnb-js-shims`
Describe the bug
I have a component that does not initialize any state.
If I shallow mount this component, when
render
is called,this.state
has a{}
value, even though I did not initialize it.Repro:
Expected behavior
this.state should be
undefined
** Versions **
Enzyme: 3.3.2
Enzyme-Adapter-React-16: 1.5.0
The text was updated successfully, but these errors were encountered: