提交 65c0014a 编写于 作者: T Tim Neutkens

Add componentDidCatch example

上级 f48b67d5
{
"babelrc": false
}
\ No newline at end of file
"presets": ["../babel"]
}
{
"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"
}
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)
}
}
export default () => {
// Render time error
throw new Error('Test')
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册