Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
cdsf-wx-app
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
姜雷
cdsf-wx-app
Commits
03d4219e
Commit
03d4219e
authored
Nov 21, 2018
by
姜雷
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'test' into 'master'
Test See merge request
!29
parents
addd1f91
ac89f7c1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
41 additions
and
0 deletions
+41
-0
ErrorBoundary.js
src/containers/ErrorCatch/ErrorBoundary.js
+37
-0
index.js
src/containers/Repair/index.js
+4
-0
No files found.
src/containers/ErrorCatch/ErrorBoundary.js
0 → 100644
View file @
03d4219e
import
React
from
'react'
;
class
ErrorBoundary
extends
React
.
Component
{
constructor
(
props
)
{
super
(
props
);
this
.
state
=
{
error
:
null
,
errorInfo
:
null
};
}
componentDidCatch
(
error
,
errorInfo
)
{
// Catch errors in any components below and re-render with error message
this
.
setState
({
error
:
error
,
errorInfo
:
errorInfo
,
});
// You can also log error messages to an error reporting service here
}
render
()
{
if
(
this
.
state
.
errorInfo
)
{
// Error path
return
(
<
div
>
<
h2
>
Something
went
wrong
.
<
/h2
>
<
details
style
=
{{
whiteSpace
:
'pre-wrap'
}}
>
{
this
.
state
.
error
&&
this
.
state
.
error
.
toString
()}
<
br
/>
{
this
.
state
.
errorInfo
.
componentStack
}
<
/details
>
<
/div
>
);
}
// Normally, just render children
return
this
.
props
.
children
;
}
}
export
default
ErrorBoundary
;
src/containers/Repair/index.js
View file @
03d4219e
...
...
@@ -3,6 +3,8 @@ import { Switch, Route, Redirect, NavLink } from 'react-router-dom';
import
styles
from
'./style.css'
;
import
ReprtRepair
from
'./ReprtRepair'
;
import
RepairList
from
'./RepairList'
;
import
ErrorBoundary
from
'../ErrorCatch/ErrorBoundary'
;
class
index
extends
Component
{
constructor
(
props
)
{
super
(
props
);
...
...
@@ -30,6 +32,7 @@ class index extends Component {
render
()
{
const
{
showFooter
}
=
this
.
state
;
return
(
<
ErrorBoundary
>
<
div
className
=
"Content-Wrap"
>
<
div
className
=
"RepairContent"
>
<
Switch
>
...
...
@@ -58,6 +61,7 @@ class index extends Component {
<
/div
>
)}
<
/div
>
<
/ErrorBoundary
>
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment