Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
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
Alex
next.js
Commits
0e39b245
Unverified
Commit
0e39b245
authored
Mar 18, 2019
by
Tim Neutkens
Committed by
GitHub
Mar 18, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean up ErrorBoundary component (#6703)
parent
b41c85e3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
24 deletions
+12
-24
error-boundary.js
packages/next/client/error-boundary.js
+0
-15
error-boundary.ts
packages/next/client/error-boundary.ts
+10
-0
index.js
packages/next/client/index.js
+2
-9
No files found.
packages/next/client/error-boundary.js
deleted
100644 → 0
View file @
b41c85e3
import
React
from
'react'
class
ErrorBoundary
extends
React
.
Component
{
componentDidCatch
(
error
,
info
)
{
const
{
onError
}
=
this
.
props
// onError is required
onError
(
error
,
info
)
}
render
()
{
const
{
children
}
=
this
.
props
return
React
.
Children
.
only
(
children
)
}
}
export
default
ErrorBoundary
packages/next/client/error-boundary.ts
0 → 100644
View file @
0e39b245
import
React
,
{
ErrorInfo
}
from
'react'
export
class
ErrorBoundary
extends
React
.
Component
<
{
fn
:
(
err
:
Error
,
info
:
ErrorInfo
)
=>
void
}
>
{
componentDidCatch
(
err
:
Error
,
info
:
ErrorInfo
)
{
this
.
props
.
fn
(
err
,
info
)
}
render
()
{
return
this
.
props
.
children
}
}
packages/next/client/index.js
View file @
0e39b245
...
@@ -6,7 +6,7 @@ import mitt from 'next-server/dist/lib/mitt'
...
@@ -6,7 +6,7 @@ import mitt from 'next-server/dist/lib/mitt'
import
{
loadGetInitialProps
,
getURL
}
from
'next-server/dist/lib/utils'
import
{
loadGetInitialProps
,
getURL
}
from
'next-server/dist/lib/utils'
import
PageLoader
from
'./page-loader'
import
PageLoader
from
'./page-loader'
import
*
as
envConfig
from
'next-server/config'
import
*
as
envConfig
from
'next-server/config'
import
ErrorBoundary
from
'./error-boundary'
import
{
ErrorBoundary
}
from
'./error-boundary'
import
Loadable
from
'next-server/dist/lib/loadable'
import
Loadable
from
'next-server/dist/lib/loadable'
import
{
HeadManagerContext
}
from
'next-server/dist/lib/head-manager-context'
import
{
HeadManagerContext
}
from
'next-server/dist/lib/head-manager-context'
...
@@ -189,15 +189,8 @@ async function doRender ({ App, Component, props, err }) {
...
@@ -189,15 +189,8 @@ async function doRender ({ App, Component, props, err }) {
),
appContainer
)
),
appContainer
)
}
else
{
}
else
{
// In production we catch runtime errors using componentDidCatch which will trigger renderError.
// In production we catch runtime errors using componentDidCatch which will trigger renderError.
const
onError
=
async
(
error
)
=>
{
try
{
await
renderError
({
App
,
err
:
error
})
}
catch
(
err
)
{
console
.
error
(
'Error while rendering error page: '
,
err
)
}
}
renderReactElement
((
renderReactElement
((
<
ErrorBoundary
onError
=
{
onError
}
>
<
ErrorBoundary
fn
=
{(
error
)
=>
renderError
({
App
,
err
:
error
}).
catch
(
err
=>
console
.
error
(
'Error rendering page: '
,
err
))
}
>
<
HeadManagerContext
.
Provider
value
=
{
headManager
.
updateHead
}
>
<
HeadManagerContext
.
Provider
value
=
{
headManager
.
updateHead
}
>
<
App
{...
appProps
}
/
>
<
App
{...
appProps
}
/
>
<
/HeadManagerContext.Provider
>
<
/HeadManagerContext.Provider
>
...
...
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