Skip to content
This repository was archived by the owner on May 25, 2020. It is now read-only.

React hot loader v4 #209

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/containers/App/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// @flow
import * as React from 'react';
import { Switch, Route, Redirect } from 'react-router-dom';

import { hot } from 'react-hot-loader';
import ErrorBoundary from 'components/ErrorBoundary';
import Header from 'components/Header';
import Budget from 'routes/Budget';
Expand All @@ -24,4 +24,4 @@ const App = () => (
</ErrorBoundary>
);

export default App;
export default hot(module)(App);
13 changes: 6 additions & 7 deletions app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { Provider } from 'react-redux';
import ReactDOM from 'react-dom';
import * as React from 'react';
import { BrowserRouter as Router } from 'react-router-dom';
import { AppContainer } from 'react-hot-loader';

import App from 'containers/App';
import store from 'store';
Expand All @@ -16,9 +15,7 @@ const renderApp = (Component: React.ComponentType<any>) => {
<React.Suspense fallback={null}>
<Provider store={store}>
<Router>
<AppContainer>
<Component />
</AppContainer>
<Component />
</Router>
</Provider>
</React.Suspense>,
Expand All @@ -28,7 +25,9 @@ const renderApp = (Component: React.ComponentType<any>) => {

renderApp(App);

// Hot Module Replacement API
if (module && module.hot && module.hot.accept) {
module.hot.accept('containers/App', () => renderApp(App));
// webpack Hot Module Replacement API
if (module.hot) {
module.hot.accept('./containers/App', () => {
renderApp(App);
});
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
"prop-types": "15.6.2",
"react": "16.6.1",
"react-dom": "16.6.1",
"react-hot-loader": "^3.0.0-beta.7",
"react-hot-loader": "4.5.0",
"react-redux": "5.0.7",
"react-router": "4.3.1",
"react-router-dom": "4.3.1",
Expand Down
3 changes: 1 addition & 2 deletions webpack.config.base.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,7 @@ module.exports = config => ({
watchOptions: {
ignored: ['node_modules', '*.svg'],
},
// hot: true,
// inline: true,
hot: true,
compress: false,
disableHostCheck: true,
stats,
Expand Down
3 changes: 0 additions & 3 deletions webpack.config.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ module.exports = require('./webpack.config.base')({

entry: {
front: [
// activate HMR for React
'react-hot-loader/patch',

// bundle the client for webpack-dev-server
// and connect to the provided endpoint
`webpack-dev-server/client?http://${host}:${port}`,
Expand Down