diff --git a/examples/.babelrc b/examples/.babelrc index 6714336e..2b5be340 100644 --- a/examples/.babelrc +++ b/examples/.babelrc @@ -1,3 +1,3 @@ { - "babelrc": false -} \ No newline at end of file + "presets": ["../babel"] +} diff --git a/examples/with-componentdidcatch/package.json b/examples/with-componentdidcatch/package.json new file mode 100644 index 00000000..a2f3b1c6 --- /dev/null +++ b/examples/with-componentdidcatch/package.json @@ -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" +} diff --git a/examples/with-componentdidcatch/pages/_app.js b/examples/with-componentdidcatch/pages/_app.js new file mode 100644 index 00000000..a2af3633 --- /dev/null +++ b/examples/with-componentdidcatch/pages/_app.js @@ -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) + } +} diff --git a/examples/with-componentdidcatch/pages/index.js b/examples/with-componentdidcatch/pages/index.js new file mode 100644 index 00000000..e9fd4786 --- /dev/null +++ b/examples/with-componentdidcatch/pages/index.js @@ -0,0 +1,4 @@ +export default () => { + // Render time error + throw new Error('Test') +}