mirror of
https://github.com/terribleplan/next.js.git
synced 2024-01-19 02:48:18 +00:00
Add componentDidCatch example
This commit is contained in:
parent
f48b67d535
commit
65c0014ad1
|
@ -1,3 +1,3 @@
|
|||
{
|
||||
"babelrc": false
|
||||
"presets": ["../babel"]
|
||||
}
|
15
examples/with-componentdidcatch/package.json
Normal file
15
examples/with-componentdidcatch/package.json
Normal file
|
@ -0,0 +1,15 @@
|
|||
{
|
||||
"name": "hello-world",
|
||||
"version": "1.0.0",
|
||||
"scripts": {
|
||||
"dev": "next",
|
||||
"build": "next build",
|
||||
"start": "next start"
|
||||
},
|
||||
"dependencies": {
|
||||
"next": "6.0.0-canary.6",
|
||||
"react": "^16.0.0",
|
||||
"react-dom": "^16.0.0"
|
||||
},
|
||||
"license": "ISC"
|
||||
}
|
9
examples/with-componentdidcatch/pages/_app.js
Normal file
9
examples/with-componentdidcatch/pages/_app.js
Normal file
|
@ -0,0 +1,9 @@
|
|||
import App from 'next/app'
|
||||
|
||||
export default class MyApp extends App {
|
||||
componentDidCatch (error, errorInfo) {
|
||||
console.log('CUSTOM ERROR HANDLING', error)
|
||||
// This is needed to render errors correctly in development / production
|
||||
super.componentDidCatch(error, errorInfo)
|
||||
}
|
||||
}
|
4
examples/with-componentdidcatch/pages/index.js
Normal file
4
examples/with-componentdidcatch/pages/index.js
Normal file
|
@ -0,0 +1,4 @@
|
|||
export default () => {
|
||||
// Render time error
|
||||
throw new Error('Test')
|
||||
}
|
Loading…
Reference in a new issue