Skip to content
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

Enable getDerivedStateFromError #13746

Merged
merged 10 commits into from Sep 28, 2018

Updated a few tests to account for a new DEV warning

  • Loading branch information...
bvaughn committed Sep 28, 2018
commit 9943c6c4e4593b8cbe61df96b41259bfda04b5c1
@@ -2004,14 +2004,19 @@ describe('ReactLegacyErrorBoundaries', () => {

it('renders empty output if error boundary does not handle the error', () => {
const container = document.createElement('div');
ReactDOM.render(
<div>
Sibling
<NoopErrorBoundary>
<BrokenRender />
</NoopErrorBoundary>
</div>,
container,
expect(() => {
ReactDOM.render(
<div>
Sibling
<NoopErrorBoundary>
<BrokenRender />
</NoopErrorBoundary>
</div>,
container,
);
}).toWarnDev(
'ErrorBoundary: Error boundaries should implement getDerivedStateFromError()',
{withoutStack: true},
);
expect(container.firstChild.textContent).toBe('Sibling');
expect(log).toEqual([
@@ -1343,6 +1343,9 @@ describe('ReactUpdates', () => {

class ErrorBoundary extends React.Component {
componentDidCatch() {
// Schedule a no-op state update to avoid triggering a DEV warning in the test.
this.setState({});

this.props.parent.remount();
}
render() {
@@ -2398,7 +2398,10 @@ describe('ReactIncremental', () => {
instance.setState({
throwError: true,
});
ReactNoop.flush();
expect(ReactNoop.flush).toWarnDev(
'Error boundaries should implement getDerivedStateFromError()',
{withoutStack: true},
);
});

it('should not recreate masked context unless inputs have changed', () => {
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.