-
-
Notifications
You must be signed in to change notification settings - Fork 2k
State is always initialized under shallow #1849
Copy link
Copy link
Closed
Description
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:
const Enzyme = require("enzyme");
const React = require("react");
class Foo extends React.Component {
constructor(props, context) {
super(props, context);
}
render() {
console.log(`State: ${JSON.stringify(this.state)}`); // prints State: {}
return (React.createElement("div", null));
}
}
it("Test render", () => {
Enzyme.shallow(React.createElement(Foo, null));
});
Expected behavior
this.state should be undefined
** Versions **
Enzyme: 3.3.2
Enzyme-Adapter-React-16: 1.5.0
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels