Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F32768891
error-boundary.react.js
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
864 B
Referenced Files
None
Subscribers
None
error-boundary.react.js
View Options
// @flow
import
*
as
React
from
'react'
;
import
type
{
ErrorInfo
,
ErrorData
}
from
'lib/types/report-types.js'
;
import
css
from
'./error-boundary.css'
;
type
Props
=
{
+
children
:
React
.
Node
,
};
type
State
=
{
+
errorData
:
$ReadOnlyArray
<
ErrorData
>
,
+
showError
:
boolean
,
};
class
ErrorBoundary
extends
React
.
PureComponent
<
Props
,
State
>
{
state
:
State
=
{
errorData
:
[],
showError
:
false
,
};
componentDidCatch
(
error
:
Error
,
info
:
ErrorInfo
)
{
this
.
setState
(
prevState
=>
({
errorData
:
[...
prevState
.
errorData
,
{
error
,
info
}],
}));
}
render
()
:
React
.
Node
{
if
(
this
.
state
.
errorData
.
length
>
0
)
{
return
(
<
div
className
=
{
css
.
container
}
>
<
h3
>
Something
has
gone
wrong
,
please
reload
the
page
<
/h3>
<
/div>
);
}
return
this
.
props
.
children
;
}
}
export
default
ErrorBoundary
;
File Metadata
Details
Attached
Mime Type
text/x-java
Expires
Fri, Jan 9, 1:24 PM (21 h, 36 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5869136
Default Alt Text
error-boundary.react.js (864 B)
Attached To
Mode
rCOMM Comm
Attached
Detach File
Event Timeline
Log In to Comment