Skip to content

Instantly share code, notes, and snippets.

@MakeHoney
Last active October 9, 2019 11:59
Show Gist options
  • Save MakeHoney/4586616e1c3234414e4e0adae4988225 to your computer and use it in GitHub Desktop.
Save MakeHoney/4586616e1c3234414e4e0adae4988225 to your computer and use it in GitHub Desktop.
react-hot-loader code snippet
// package.json
...
"react-hot-loader": "^4.12.15",
"@hot-loader/react-dom": "^16.8.6",
...
// webpack.config.js
module.exports = {
...
resolve: {
alias: {
'react-dom': '@hot-loader/react-dom'
}
},
...
plugins: [
...
new webpack.HotModuleReplacementPlugin()
...
],
...
devServer: {
...
hot: true,
inline: true,
...
}
}
// App.js
import React from 'react'
...
import { hot } from 'react-hot-loader'
const App = () => {
return (
...
)
}
export default hot(module)(App)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment