-
Notifications
You must be signed in to change notification settings - Fork 50.6k
Closed
Description
Do you want to request a feature or report a bug?
bug
What is the current behavior?
componentWillUnmount for inner instances is never called.
Here are 2 (jest) tests, the first works, not the second.
import React from "react";
import renderer from "react-test-renderer";
test("top level componentWillUnmount works", () => {
let count = 0;
class A extends React.Component {
componentWillUnmount() {
count ++;
}
render() {
return <div />;
}
}
const inst = renderer.create(<A />);
inst.unmount();
expect(count).toEqual(1);
});
test("inner componentWillUnmount works", () => {
let count = 0;
class A extends React.Component {
componentWillUnmount() {
count ++;
}
render() {
return <div />;
}
}
const inst = renderer.create(
<div>
<A />
</div>
);
inst.unmount();
expect(count).toEqual(1);
});What is the expected behavior?
The two test above should pass. All component that are unmounted should have the proper lifecycle, whatever the nesting is.
Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?
React 15.4.0
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels