-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
28 lines (25 loc) · 793 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import React from 'react';
import { hydrate } from 'react-dom';
import { AppContainer } from 'react-hot-loader';
import Client from './App/Client';
/*
* Define a render method to make another component wrapped inside
* <AppContainer/> for to allow Hot Loader for development via `hydrate`
* Then render inside a HTML element called #app
*/
const render = (Component) => {
hydrate(
<AppContainer>
<Component />
</AppContainer>,
document.getElementById('app'),
);
};
// By default, render a client
render(Client);
/*
* If Hot Module Replacement has been enabled via the HotModuleReplacementPlugin
* Accept update for Client app
* Then render a new Client app with predefined `render` method
*/
if (module.hot) module.hot.accept('./App/Client.js', () => render(Client));