You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We recently upgraded out React dependency to 0.14. To my surprise this caused some of our skin-deep powered tests to fail with TypeError: Cannot read property '_currentElement' of null.
The skin-deep test suite passes with flying colours in our setup, so I was a bit stumped. Eventually I found the cause of the error to be a call to setState in componentWillMount.
The error originates in react/lib/ReactCompositeComponent, which is why I'm unsure of whether I should be reporting it here or rather to the React project. If I'm in the wrong place, speak up and I will move on.
See a failing test below this line.
import React, { Component } from "react"; // 0.14
import test from "tape";
import sd from "skin-deep";
class FailingComp extends Component {
constructor(props) {
super(props);
this.state = {};
}
componentWillMount() {
// comment the line below to pass the test
this.setState({ hello: "World!" });
}
render() {
const { hello = "World" } = this.state;
return <p>{`Hello ${hello}!`}</p>;
}
}
test("component", t => {
const render = (props = {}) => {
const tree = sd.shallowRender(React.createElement(FailingComp, props));
const inst = tree.getMountedInstance();
const vdom = tree.getRenderOutput();
return { tree, inst, vdom };
};
const { vdom } = render();
t.equal(vdom.type, "p", "renders p-tag");
t.deepEqual(vdom.props.children, "Hello World!", "contains the text 'Hello World!'");
t.end();
});
The text was updated successfully, but these errors were encountered:
We recently upgraded out React dependency to 0.14. To my surprise this caused some of our skin-deep powered tests to fail with
TypeError: Cannot read property '_currentElement' of null
.The skin-deep test suite passes with flying colours in our setup, so I was a bit stumped. Eventually I found the cause of the error to be a call to
setState
incomponentWillMount
.The error originates in
react/lib/ReactCompositeComponent
, which is why I'm unsure of whether I should be reporting it here or rather to the React project. If I'm in the wrong place, speak up and I will move on.See a failing test below this line.
The text was updated successfully, but these errors were encountered: