Skip to content

Commit 81feb7f

Browse files
committed
feat: remove AppContainer from RHL3, mark App container as hot-exported.
1 parent 0c2f70f commit 81feb7f

File tree

2 files changed

+13
-30
lines changed

2 files changed

+13
-30
lines changed

client/index.js

Lines changed: 11 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3,39 +3,21 @@ import React from 'react';
33
import ReactDOM from 'react-dom';
44
import { Provider } from 'react-redux';
55
import { ConnectedRouter } from 'react-router-redux';
6-
import { AppContainer } from 'react-hot-loader';
76
import createHistory from 'history/createBrowserHistory';
87
import configureStore from 'store';
98
import App from 'containers/App';
109

11-
const history = createHistory();
12-
13-
// The root element of your app
14-
const rootElement = document.getElementById('app');
15-
16-
// Creates the Redux store based on the initial state passed down by the server
17-
// rendering.
10+
// Hydrate the redux store from server state.
1811
const initialState = window.__INITIAL_STATE__;
12+
const history = createHistory();
1913
const store = configureStore(initialState, history);
2014

21-
const render = (Component) => {
22-
ReactDOM.hydrate(
23-
<Provider store={store}>
24-
<AppContainer>
25-
<ConnectedRouter history={history}>
26-
<Component />
27-
</ConnectedRouter>
28-
</AppContainer>
29-
</Provider>,
30-
rootElement
31-
);
32-
};
33-
34-
render(App);
35-
36-
if (module.hot) {
37-
// We need to re-require the main App module.
38-
module.hot.accept('../common/js/containers/App', () => {
39-
render(require('../common/js/containers/App').default);
40-
});
41-
}
15+
// Render the application
16+
ReactDOM.hydrate(
17+
<Provider store={store}>
18+
<ConnectedRouter history={history}>
19+
<App />
20+
</ConnectedRouter>
21+
</Provider>,
22+
document.getElementById('app')
23+
);

common/js/containers/App/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { Switch } from 'react-router-dom';
33
import { RouteWithSubRoutes } from 'components/common';
44
import { Container } from 'semantic-ui-react';
55
import { Header, Footer } from 'components/common';
6+
import { hot } from 'react-hot-loader';
67
import routes from 'routes';
78

89
const App = () => (
@@ -17,4 +18,4 @@ const App = () => (
1718
</Container>
1819
);
1920

20-
export default App;
21+
export default hot(module)(App);

0 commit comments

Comments
 (0)