-
-
Notifications
You must be signed in to change notification settings - Fork 87
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 #194 from jdbranham/master
Updates from master
- Loading branch information
Showing
6 changed files
with
79 additions
and
21 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
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
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,34 @@ | ||
import React from 'react'; | ||
|
||
interface DiagramErrorBoundaryProps { | ||
children: React.ReactNode; | ||
fallback?: React.ReactNode | string; | ||
} | ||
|
||
interface DiagramErrorBoundaryState { | ||
hasError: boolean; | ||
} | ||
|
||
class DiagramErrorBoundary extends React.Component<DiagramErrorBoundaryProps, DiagramErrorBoundaryState> { | ||
constructor(props: any) { | ||
super(props); | ||
this.state = { hasError: false }; | ||
} | ||
|
||
static getDerivedStateFromError(error: any) { | ||
// Update state so the next render will show the fallback UI. | ||
return { hasError: true }; | ||
} | ||
|
||
render() { | ||
if (this.state.hasError) { | ||
// Render fallback | ||
const Fallback = this.props.fallback ? this.props.fallback : 'Error rendering component'; | ||
return <div>{Fallback}</div>; | ||
} | ||
|
||
return this.props.children; | ||
} | ||
} | ||
|
||
export default DiagramErrorBoundary; |
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