forked from sombochea/verdaccio-ui
* chore: refactoring version page * refactor: migrate version page to hooks * refactor: Version page better imports * fix: #100 render not found on click item * test: add test for version page * chore: update mocks * test: add scenario for not found package * chore: fix wrong mock path * chore: update mock * chore: add todo list
This commit is contained in:
committed by
GitHub
parent
e7d3c461cd
commit
97e8448098
38
src/App/AppError.tsx
Normal file
38
src/App/AppError.tsx
Normal file
@@ -0,0 +1,38 @@
|
||||
import React, { Component } from 'react';
|
||||
|
||||
export interface ErrorProps {
|
||||
children: any;
|
||||
}
|
||||
|
||||
export interface ErrorAppState {
|
||||
hasError: boolean;
|
||||
error: any;
|
||||
info: any;
|
||||
}
|
||||
|
||||
export default class ErrorBoundary extends Component<ErrorProps, ErrorAppState> {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = { hasError: false, error: null, info: null };
|
||||
}
|
||||
|
||||
componentDidCatch(error, info) {
|
||||
this.setState({ hasError: true, error, info });
|
||||
}
|
||||
|
||||
render() {
|
||||
const { hasError, error, info } = this.state;
|
||||
const { children } = this.props;
|
||||
|
||||
if (hasError) {
|
||||
return (
|
||||
<>
|
||||
<h1>{'Something went wrong.'}</h1>
|
||||
<p>{`error: ${error}`}</p>
|
||||
<p>{`info: ${JSON.stringify(info)}`}</p>
|
||||
</>
|
||||
);
|
||||
}
|
||||
return children;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user