forked from decentraland/marketplace
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: error boundary (decentraland#495)
* fix: typescript path * fix: ignore .vscode * feat: added error boundary, fixed empty estate detail * chore: remove comments from docs
- Loading branch information
Showing
12 changed files
with
118 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -72,3 +72,4 @@ indexer/src/entities | |
indexer/src/data/addresses.ts | ||
indexer/subgraph.yaml | ||
|
||
.vscode |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
webapp/src/components/AssetPage/ErrorBoundary/ErrorBoundary.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import React from 'react' | ||
import { t } from 'decentraland-dapps/dist/modules/translation/utils' | ||
import { Center } from 'decentraland-ui' | ||
import { Props, State } from './ErrorBoundary.types' | ||
|
||
export default class ErrorBoundary extends React.Component<Props, State> { | ||
constructor(props: Props) { | ||
super(props) | ||
this.state = { hasError: false } | ||
} | ||
|
||
static getDerivedStateFromError(_error: Error) { | ||
return { hasError: true } | ||
} | ||
|
||
componentDidCatch(error: Error, errorInfo: any) { | ||
console.error(error, errorInfo) | ||
} | ||
|
||
render() { | ||
if (this.state.hasError) { | ||
return ( | ||
<Center> | ||
<div className="secondary-text">{t('error_boundary.message')}</div> | ||
</Center> | ||
) | ||
} | ||
|
||
return this.props.children | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
webapp/src/components/AssetPage/ErrorBoundary/ErrorBoundary.types.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export type Props = {} | ||
|
||
export type State = { | ||
hasError: boolean | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import ErrorBoundary from './ErrorBoundary' | ||
export { ErrorBoundary } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters