-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
de0c2fd
commit dccc3ad
Showing
2 changed files
with
51 additions
and
3 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 |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import Typography from '@material-ui/core/Typography'; | ||
import Link from '@material-ui/core/Link'; | ||
|
||
export default class DemoErrorBoundary extends React.Component { | ||
state = { | ||
error: null, | ||
}; | ||
|
||
static getDerivedStateFromError(error) { | ||
return { error }; | ||
} | ||
|
||
render() { | ||
const { children } = this.props; | ||
const { error } = this.state; | ||
|
||
if (error) { | ||
/* eslint-disable material-ui/no-hardcoded-labels */ | ||
return ( | ||
<div> | ||
<Typography color="error" component="p" variant="h5" gutterBottom> | ||
This demo had a runtime error! | ||
</Typography> | ||
<Typography> | ||
We would appreciate it if you report this error directly to our{' '} | ||
<Link href="https://github.com/mui-org/material-ui/issues/new/choose" target="_blank"> | ||
issue tracker | ||
</Link> | ||
. | ||
</Typography> | ||
<pre>{error.toString()}</pre> | ||
</div> | ||
); | ||
/* eslint-enable material-ui/no-hardcoded-labels */ | ||
} | ||
|
||
return children; | ||
} | ||
} | ||
|
||
DemoErrorBoundary.propTypes = { | ||
children: PropTypes.node, | ||
}; |
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