From c675c42301e20f83abd8f1cdb1ba8b7978f3fe04 Mon Sep 17 00:00:00 2001 From: Kevin Ghadyani Date: Thu, 17 Nov 2016 23:46:28 -0600 Subject: [PATCH] Integrated latest react-hot-loader 3.0.0 beta 6 (not hot reloading) --- includes/webpack-dev-client-config.coffee | 4 +++- src/code/client.jsx | 26 +++++++++++++++++------ src/code/root.jsx | 14 ++++++++++++ 3 files changed, 37 insertions(+), 7 deletions(-) create mode 100644 src/code/root.jsx diff --git a/includes/webpack-dev-client-config.coffee b/includes/webpack-dev-client-config.coffee index 2828863..46def14 100644 --- a/includes/webpack-dev-client-config.coffee +++ b/includes/webpack-dev-client-config.coffee @@ -10,11 +10,13 @@ happyThreadPool = HappyPack.ThreadPool size: 4 webpackConfig = entry: main: [ + 'react-hot-loader/patch' 'webpack-dev-server/client?' + config.getServerUrl() 'webpack/hot/dev-server' './' + paths.code.src + 'client' ] tests: [ + 'react-hot-loader/patch' 'webpack-dev-server/client?' + config.getServerUrl() 'webpack/hot/dev-server' './' + paths.code.src + 'tests' @@ -44,7 +46,7 @@ webpackConfig = new webpack.DefinePlugin 'process.env.NODE_ENV': JSON.stringify config.getEnv() new HappyPack id: 'jsx', threadPool: happyThreadPool, loaders: [ - 'react-hot' + 'react-hot-loader/webpack' 'babel' ] new HappyPack diff --git a/src/code/client.jsx b/src/code/client.jsx index 02645b8..583e101 100644 --- a/src/code/client.jsx +++ b/src/code/client.jsx @@ -1,14 +1,17 @@ import React from 'react' import { render } from 'react-dom' -import { match, browserHistory, Router, Route, Redirect, Link } from 'react-router' -import { Provider } from 'react-redux' +import { match } from 'react-router' +import { AppContainer } from 'react-hot-loader' + +// Root Component +import Root from 'root' // Polyfills import 'react-fastclick' import 'utilities/polyfills' // Store and Routes -import { history, store } from 'utilities/store' +import { history } from 'utilities/store' import routes from './routes' // Router @@ -18,8 +21,19 @@ match({ history, routes }, (error, redirectLocation, renderProps) => { } render( - - - + + + , document.getElementById('root')) + + if (module.hot) { + module.hot.accept('./root', () => { + const RootContainer = require('./root').default + render( + + + + , document.getElementById('root')) + }) + } }) diff --git a/src/code/root.jsx b/src/code/root.jsx new file mode 100644 index 0000000..80e41c4 --- /dev/null +++ b/src/code/root.jsx @@ -0,0 +1,14 @@ +import React, { Component } from 'react' +import { Provider } from 'react-redux' +import { browserHistory, Router } from 'react-router' + +// Store and Routes +import { store } from 'utilities/store' + +export default class Root extends Component { + render() { return ( + + + + )} +}