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
Describe the bug
I have a component that does not initialize any state.
If I shallow mount this component, when
renderis called,this.statehas 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