Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
interface
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
LuckySwap
interface
Commits
5cf9e84d
Unverified
Commit
5cf9e84d
authored
Mar 31, 2022
by
Moody Salem
Committed by
GitHub
Mar 31, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(error handling): try reloading the app when encountering a javascript error (#3435)
parent
c0bdb8db
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
0 deletions
+12
-0
index.tsx
src/components/ErrorBoundary/index.tsx
+12
-0
No files found.
src/components/ErrorBoundary/index.tsx
View file @
5cf9e84d
...
@@ -49,6 +49,11 @@ type ErrorBoundaryState = {
...
@@ -49,6 +49,11 @@ type ErrorBoundaryState = {
const
IS_UNISWAP
=
window
.
location
.
hostname
===
'
app.uniswap.org
'
const
IS_UNISWAP
=
window
.
location
.
hostname
===
'
app.uniswap.org
'
async
function
updateServiceWorker
():
Promise
<
void
>
{
const
ready
=
await
navigator
.
serviceWorker
.
ready
await
ready
.
update
()
}
export
default
class
ErrorBoundary
extends
React
.
Component
<
unknown
,
ErrorBoundaryState
>
{
export
default
class
ErrorBoundary
extends
React
.
Component
<
unknown
,
ErrorBoundaryState
>
{
constructor
(
props
:
unknown
)
{
constructor
(
props
:
unknown
)
{
super
(
props
)
super
(
props
)
...
@@ -56,6 +61,13 @@ export default class ErrorBoundary extends React.Component<unknown, ErrorBoundar
...
@@ -56,6 +61,13 @@ export default class ErrorBoundary extends React.Component<unknown, ErrorBoundar
}
}
static
getDerivedStateFromError
(
error
:
Error
):
ErrorBoundaryState
{
static
getDerivedStateFromError
(
error
:
Error
):
ErrorBoundaryState
{
updateServiceWorker
()
.
then
(()
=>
{
window
.
location
.
reload
()
})
.
catch
((
error
)
=>
{
console
.
error
(
'
Failed to update service worker
'
,
error
)
})
return
{
error
}
return
{
error
}
}
}
...
...
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