From a2ad803e8133536f7c9eeeeba0924a906a941d7d Mon Sep 17 00:00:00 2001 From: Tom Kirkpatrick Date: Sat, 28 Jul 2018 14:21:36 +0200 Subject: [PATCH] refactor(react): migrate to React Hot Loader v4 Update RHL implementation to recommended v4 semantics. See https://github.com/gaearon/react-hot-loader#migrating-from-v3 --- app/containers/Root.js | 13 ++++++++----- app/index.js | 8 +------- webpack.config.renderer.dev.js | 15 ++------------- 3 files changed, 11 insertions(+), 25 deletions(-) diff --git a/app/containers/Root.js b/app/containers/Root.js index edc6eaf1..c03fd1c4 100644 --- a/app/containers/Root.js +++ b/app/containers/Root.js @@ -3,6 +3,7 @@ import React from 'react' import { Provider, connect } from 'react-redux' import { ConnectedRouter } from 'react-router-redux' import PropTypes from 'prop-types' +import { hot } from 'react-hot-loader' import { setConnectionType, @@ -243,8 +244,10 @@ Root.propTypes = { syncingProps: PropTypes.object.isRequired } -export default connect( - mapStateToProps, - mapDispatchToProps, - mergeProps -)(Root) +export default hot(module)( + connect( + mapStateToProps, + mapDispatchToProps, + mergeProps + )(Root) +) diff --git a/app/index.js b/app/index.js index b292d8b0..ca5cf49c 100644 --- a/app/index.js +++ b/app/index.js @@ -16,12 +16,6 @@ render( if (module.hot) { module.hot.accept('./containers/Root', () => { - const NextRoot = require('./containers/Root') // eslint-disable-line global-require - render( - - - , - document.getElementById('root') - ) + render(, document.getElementById('root')) }) } diff --git a/webpack.config.renderer.dev.js b/webpack.config.renderer.dev.js index 438846ce..67303d1a 100644 --- a/webpack.config.renderer.dev.js +++ b/webpack.config.renderer.dev.js @@ -44,11 +44,7 @@ export default merge.smart(baseConfig, { mode: 'development', - entry: [ - 'react-hot-loader/patch', - 'webpack/hot/only-dev-server', - path.join(__dirname, 'app/index.js') - ], + entry: ['webpack/hot/only-dev-server', path.join(__dirname, 'app/index.js')], output: { publicPath: `http://localhost:${port}/dist/` @@ -296,14 +292,7 @@ export default merge.smart(baseConfig, { }) ) ) - app.use( - convert( - history({ - verbose: true, - disableDotRule: false - }) - ) - ) + app.use(convert(history())) }, // Start the main process as soon as the server is listening. on: {