Fix React hot module reloading
This commit is contained in:
parent
ac4d290a28
commit
e303f37572
37
src/index.js
37
src/index.js
|
@ -16,7 +16,13 @@ import Nav from './ui/navigation';
|
||||||
import Main from './ui/main';
|
import Main from './ui/main';
|
||||||
import Connection from './ui/connection';
|
import Connection from './ui/connection';
|
||||||
|
|
||||||
|
let skip_init = false;
|
||||||
|
|
||||||
export function initialize(uri) {
|
export function initialize(uri) {
|
||||||
|
if (skip_init) {
|
||||||
|
skip_init = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
store.dispatch(socket_uri(uri));
|
store.dispatch(socket_uri(uri));
|
||||||
store.dispatch(socket_update(SOCKET_STATE.CONNECTING));
|
store.dispatch(socket_update(SOCKET_STATE.CONNECTING));
|
||||||
ws_init(uri, () => {
|
ws_init(uri, () => {
|
||||||
|
@ -29,17 +35,28 @@ export function initialize(uri) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
ReactDOM.render(
|
const render = main =>
|
||||||
<Provider store={store}>
|
ReactDOM.render(
|
||||||
<ConnectedRouter history={history}>
|
<Provider store={store}>
|
||||||
<div>
|
<ConnectedRouter history={history}>
|
||||||
<Nav />
|
<div>
|
||||||
<div className="container-fluid">
|
<Nav />
|
||||||
<Main />
|
<div className="container-fluid">
|
||||||
|
{main}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</ConnectedRouter>
|
||||||
</ConnectedRouter>
|
</Provider>, document.getElementById('root'));
|
||||||
</Provider>, document.getElementById('root'));
|
|
||||||
|
render(<Main />);
|
||||||
|
|
||||||
|
if (module.hot) {
|
||||||
|
module.hot.accept('./ui/main.js', () => {
|
||||||
|
const NextMain = require('./ui/main.js').default;
|
||||||
|
skip_init = true;
|
||||||
|
render(<NextMain />, document.getElementById('react-root'));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
navigator.registerProtocolHandler("magnet",
|
navigator.registerProtocolHandler("magnet",
|
||||||
window.location.origin + "/add-torrent/%s",
|
window.location.origin + "/add-torrent/%s",
|
||||||
|
|
Loading…
Reference in New Issue
Block a user