Browse Source

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
renovate/lint-staged-8.x
Tom Kirkpatrick 7 years ago
parent
commit
a2ad803e81
No known key found for this signature in database GPG Key ID: 72203A8EC5967EA8
  1. 13
      app/containers/Root.js
  2. 8
      app/index.js
  3. 15
      webpack.config.renderer.dev.js

13
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)
)

8
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(
<AppContainer>
<NextRoot store={store} history={history} />
</AppContainer>,
document.getElementById('root')
)
render(<Root store={store} history={history} />, document.getElementById('root'))
})
}

15
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: {

Loading…
Cancel
Save