From 6d45dfda431b0136b9b3845ca79e81768b95cc1e Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Mon, 29 Feb 2016 01:33:29 +0000 Subject: [PATCH] RFC: remove React Transform from examples --- examples/async/.babelrc | 7 +---- examples/async/index.js | 44 ++++++++++++++++++++++++++------ examples/async/package.json | 2 +- examples/async/webpack.config.js | 1 - 4 files changed, 38 insertions(+), 16 deletions(-) diff --git a/examples/async/.babelrc b/examples/async/.babelrc index d0962f5695..86c445f545 100644 --- a/examples/async/.babelrc +++ b/examples/async/.babelrc @@ -1,8 +1,3 @@ { - "presets": ["es2015", "react"], - "env": { - "development": { - "presets": ["react-hmre"] - } - } + "presets": ["es2015", "react"] } diff --git a/examples/async/index.js b/examples/async/index.js index 12bcb25c37..f4c7c77ab1 100644 --- a/examples/async/index.js +++ b/examples/async/index.js @@ -1,15 +1,43 @@ import 'babel-polyfill' import React from 'react' -import { render } from 'react-dom' +import ReactDOM from 'react-dom' import { Provider } from 'react-redux' -import App from './containers/App' import configureStore from './store/configureStore' const store = configureStore() +const rootEl = document.getElementById('root') -render( - - - , - document.getElementById('root') -) +let render = () => { + const App = require('./containers/App').default + ReactDOM.render( + + + , + rootEl + ) +} + +if (module.hot) { + // Support hot reloading of components + // and display an overlay for runtime errors + const renderApp = render + const renderError = (error) => { + const RedBox = require('redbox-react') + ReactDOM.render( + , + rootEl + ) + } + render = () => { + try { + renderApp() + } catch (error) { + renderError(error) + } + } + module.hot.accept('./containers/App', () => { + setTimeout(render) + }) +} + +render() diff --git a/examples/async/package.json b/examples/async/package.json index 6c34136b1e..2d24329f4b 100644 --- a/examples/async/package.json +++ b/examples/async/package.json @@ -40,10 +40,10 @@ "babel-loader": "^6.2.0", "babel-preset-es2015": "^6.3.13", "babel-preset-react": "^6.3.13", - "babel-preset-react-hmre": "^1.0.1", "expect": "^1.6.0", "express": "^4.13.3", "node-libs-browser": "^0.5.2", + "redbox-react": "^1.2.2", "webpack": "^1.9.11", "webpack-dev-middleware": "^1.2.0", "webpack-hot-middleware": "^2.2.0" diff --git a/examples/async/webpack.config.js b/examples/async/webpack.config.js index f71daecee2..038e12dd32 100644 --- a/examples/async/webpack.config.js +++ b/examples/async/webpack.config.js @@ -15,7 +15,6 @@ module.exports = { plugins: [ new webpack.optimize.OccurenceOrderPlugin(), new webpack.HotModuleReplacementPlugin(), - new webpack.NoErrorsPlugin() ], module: { loaders: [