Skip to content

Commit a691cd5

Browse files
committed
update tests
1 parent b72ce7c commit a691cd5

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

src/diff/catch-error.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,13 @@ export function _catchError(error, vnode) {
1616

1717
if (ctor && ctor.getDerivedStateFromError != null) {
1818
component.setState(ctor.getDerivedStateFromError(error));
19+
if (!component._dirty) component.forceUpdate();
1920
handled = true;
2021
}
2122

2223
if (component.componentDidCatch != null) {
2324
component.componentDidCatch(error);
25+
if (!component._dirty) component.forceUpdate();
2426
handled = true;
2527
}
2628

test/browser/lifecycles/getDerivedStateFromError.test.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ describe('Lifecycle methods', () => {
531531

532532
it('should bubble on ignored errors', () => {
533533
class Adapter extends Component {
534-
static getDerivedStateFromError(error) {
534+
static getDerivedStateFromError() {
535535
// Ignore the error
536536
return null;
537537
}
@@ -554,9 +554,11 @@ describe('Lifecycle methods', () => {
554554
</Receiver>,
555555
scratch
556556
);
557-
rerender();
558557

558+
rerender();
559559
expect(Adapter.getDerivedStateFromError).to.have.been.called;
560+
561+
rerender();
560562
expect(Receiver.getDerivedStateFromError).to.have.been.called;
561563
expect(scratch).to.have.property('textContent', 'Error: Error!');
562564
});

0 commit comments

Comments
 (0)