Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit ac1baa3

Browse files
common components changed to new foler
1 parent a8cc0b6 commit ac1baa3

File tree

5 files changed

+33
-2
lines changed

5 files changed

+33
-2
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import React, { Component } from 'react';
2+
3+
export default class ErrorBoundary extends Component {
4+
constructor(props) {
5+
super(props);
6+
this.state = { hasError: false };
7+
}
8+
9+
static getDerivedStateFromError(error) {
10+
console.log(error);
11+
// Update state so the next render will show the fallback UI.
12+
return { hasError: true };
13+
}
14+
15+
componentDidCatch(error, errorInfo) {
16+
// You can also log the error to an error reporting service
17+
console.log(error, errorInfo);
18+
}
19+
20+
render() {
21+
if (this.state.hasError) {
22+
// You can render any custom fallback UI
23+
return <h1>Something went wrong.</h1>;
24+
}
25+
26+
return this.props.children;
27+
}
28+
}
File renamed without changes.

src/components/common/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export { default as ErrorBoundary } from './ErrorBoundary';
2+
export { default as Loader } from './Loader';

src/components/routes/index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
11
export { default as AuthRoute } from './AuthRoute';
2-
export { default as Loader } from './Loader';
32
export { default as PrivateRoute } from './PrivateRoute';

src/router.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import React from 'react';
22
import { Layout } from 'antd';
33
import { BrowserRouter, Switch, Route } from 'react-router-dom';
4-
import { AuthRoute, PrivateRoute, Loader } from './components/routes';
4+
import { AuthRoute, PrivateRoute } from './components/routes';
5+
import { Loader } from './components/common';
6+
57
import * as Pages from './pages';
68

79
const { Content } = Layout;

0 commit comments

Comments
 (0)