Skip to content

Commit

Permalink
POC
Browse files Browse the repository at this point in the history
  • Loading branch information
marcin-piela committed May 13, 2019
1 parent 082888a commit bcdebf2
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/components/queryErrorBoundary/QueryErrorBoundary.tsx
@@ -1,8 +1,13 @@
import React, { Component } from 'react';
import { ErrorQueryBoundaryState, ErrorQueryBoundaryProps } from './QueryErrorBoundary.types';
import { QueryError } from '../../client/errors/QueryError';
import { ErrorQueryBoundaryProps, ErrorQueryBoundaryState } from './QueryErrorBoundary.types';

export class QueryErrorBoundary extends Component<ErrorQueryBoundaryProps, ErrorQueryBoundaryState> {
static getDerivedStateFromError(error: Error) {
if (error instanceof QueryError) {
return { hasError: true, status: error.status };
}
}
state: ErrorQueryBoundaryState = {
hasError: false,
};
Expand All @@ -12,12 +17,6 @@ export class QueryErrorBoundary extends Component<ErrorQueryBoundaryProps, Error
this.state = { hasError: false };
}

static getDerivedStateFromError(error: Error) {
if (error instanceof QueryError) {
return { hasError: true, status: error.status };
}
}

render() {
if (this.state.hasError && this.state.status && this.props.statuses.includes(this.state.status)) {
return this.props.fallback(this.state.status);
Expand Down

0 comments on commit bcdebf2

Please sign in to comment.