-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9799 from marmelab/feat/global-errorboundary
Add a global ErrorBoundary
- Loading branch information
Showing
14 changed files
with
312 additions
and
95 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
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,41 @@ | ||
import * as React from 'react'; | ||
import { Route } from 'react-router'; | ||
import { CoreAdmin } from './CoreAdmin'; | ||
import { CustomRoutes } from './CustomRoutes'; | ||
|
||
export default { | ||
title: 'ra-core/core/CoreAdmin', | ||
}; | ||
|
||
const BuggyComponent = () => { | ||
throw new Error('Something went wrong...'); | ||
}; | ||
|
||
export const DefaultError = () => ( | ||
<CoreAdmin> | ||
<CustomRoutes noLayout> | ||
<Route path="/" element={<BuggyComponent />} /> | ||
</CustomRoutes> | ||
</CoreAdmin> | ||
); | ||
|
||
const MyError = ({ | ||
error, | ||
errorInfo, | ||
}: { | ||
error?: Error; | ||
errorInfo?: React.ErrorInfo; | ||
}) => ( | ||
<div style={{ backgroundColor: 'purple', color: 'white', height: '100vh' }}> | ||
<h1>{error?.message}</h1> | ||
<pre>{errorInfo?.componentStack}</pre> | ||
</div> | ||
); | ||
|
||
export const CustomError = () => ( | ||
<CoreAdmin error={MyError}> | ||
<CustomRoutes noLayout> | ||
<Route path="/" element={<BuggyComponent />} /> | ||
</CustomRoutes> | ||
</CoreAdmin> | ||
); |
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
Oops, something went wrong.