1
0
Fork 0
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:
Tim Neutkens 2018-04-23 14:22:36 -07:00
parent f48b67d535
commit 65c0014ad1
4 changed files with 30 additions and 2 deletions

View file

@ -1,3 +1,3 @@
{
"babelrc": false
"presets": ["../babel"]
}

View 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"
}

View 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)
}
}

View file

@ -0,0 +1,4 @@
export default () => {
// Render time error
throw new Error('Test')
}