From 921bfe1486dc61c2962defc164dabfc5fb9de9a1 Mon Sep 17 00:00:00 2001 From: Arunoda Susiripala Date: Thu, 27 Jul 2017 15:09:33 +0530 Subject: [PATCH] Initial support for React fiber. --- client/next-dev.js | 15 --------------- lib/app.js | 14 ++++++++++++++ package.json | 4 ++-- yarn.lock | 18 +++++++++--------- 4 files changed, 25 insertions(+), 26 deletions(-) diff --git a/client/next-dev.js b/client/next-dev.js index c5816fbd85fbc..52ba3ad07f21c 100644 --- a/client/next-dev.js +++ b/client/next-dev.js @@ -1,5 +1,4 @@ import 'react-hot-loader/patch' -import ReactReconciler from 'react-dom/lib/ReactReconciler' import initOnDemandEntries from './on-demand-entries-client' import initWebpackHMR from './webpack-hot-middleware-client' @@ -35,17 +34,3 @@ next.default() .catch((err) => { console.error(`${err.message}\n${err.stack}`) }) - -// This is a patch to catch most of the errors throw inside React components. -const originalMountComponent = ReactReconciler.mountComponent -ReactReconciler.mountComponent = function (...args) { - try { - return originalMountComponent(...args) - } catch (err) { - if (!err.abort) { - next.renderError(err) - err.abort = true - } - throw err - } -} diff --git a/lib/app.js b/lib/app.js index b42579e6050a3..5de3afb7d65f9 100644 --- a/lib/app.js +++ b/lib/app.js @@ -4,6 +4,10 @@ import shallowEquals from './shallow-equals' import { warn } from './utils' export default class App extends Component { + state = { + error: null + } + static childContextTypes = { headManager: PropTypes.object } @@ -13,7 +17,17 @@ export default class App extends Component { return { headManager } } + componentDidCatch (error, errorInfo) { + error.stack = `${error.stack}\n\n${errorInfo.componentStack}` + window.next.renderError(error) + this.setState({ error }) + } + render () { + if (this.state.error) { + return null + } + const { Component, props, hash, router } = this.props const url = createUrl(router) // If there no component exported we can't proceed. diff --git a/package.json b/package.json index e595613b7255d..f5f2ad68b6981 100644 --- a/package.json +++ b/package.json @@ -126,8 +126,8 @@ "node-notifier": "5.1.2", "nyc": "11.0.3", "portfinder": "^1.0.13", - "react": "15.5.4", - "react-dom": "15.5.4", + "react": "next", + "react-dom": "next", "standard": "9.0.2", "taskr": "1.0.6", "wd": "1.4.0" diff --git a/yarn.lock b/yarn.lock index fb8f2aa17c9f2..e558a05ca6135 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4394,7 +4394,7 @@ prop-types-exact@^1.1.1: has "^1.0.1" object.assign "^4.0.4" -prop-types@15.5.10, prop-types@^15.5.4, prop-types@^15.5.7, prop-types@~15.5.7: +prop-types@15.5.10, prop-types@^15.5.4, prop-types@^15.5.6: version "15.5.10" resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.5.10.tgz#2797dfc3126182e3a95e3dfbb2e893ddd7456154" dependencies: @@ -4484,14 +4484,14 @@ react-deep-force-update@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/react-deep-force-update/-/react-deep-force-update-2.0.1.tgz#4f7f6c12c3e7de42f345992a3c518236fa1ecad3" -react-dom@15.5.4: - version "15.5.4" - resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-15.5.4.tgz#ba0c28786fd52ed7e4f2135fe0288d462aef93da" +react-dom@next: + version "16.0.0-beta.1" + resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-16.0.0-beta.1.tgz#be3e958578dae850884f7abd7ba559f9dfb39815" dependencies: fbjs "^0.8.9" loose-envify "^1.1.0" object-assign "^4.1.0" - prop-types "~15.5.7" + prop-types "^15.5.6" react-hot-loader@3.0.0-beta.7: version "3.0.0-beta.7" @@ -4510,14 +4510,14 @@ react-proxy@^3.0.0-alpha.0: dependencies: lodash "^4.6.1" -react@15.5.4: - version "15.5.4" - resolved "https://registry.yarnpkg.com/react/-/react-15.5.4.tgz#fa83eb01506ab237cdc1c8c3b1cea8de012bf047" +react@next: + version "16.0.0-beta.1" + resolved "https://registry.yarnpkg.com/react/-/react-16.0.0-beta.1.tgz#c02171171e9638b0c506f5a26b90e918f76909ab" dependencies: fbjs "^0.8.9" loose-envify "^1.1.0" object-assign "^4.1.0" - prop-types "^15.5.7" + prop-types "^15.5.6" read-pkg-up@^1.0.1: version "1.0.1"