Fix React hot module reloading
This commit is contained in:
parent
ac4d290a28
commit
e303f37572
19
src/index.js
19
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,18 +35,29 @@ export function initialize(uri) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const render = main =>
|
||||||
ReactDOM.render(
|
ReactDOM.render(
|
||||||
<Provider store={store}>
|
<Provider store={store}>
|
||||||
<ConnectedRouter history={history}>
|
<ConnectedRouter history={history}>
|
||||||
<div>
|
<div>
|
||||||
<Nav />
|
<Nav />
|
||||||
<div className="container-fluid">
|
<div className="container-fluid">
|
||||||
<Main />
|
{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",
|
||||||
"Open magnet link with receptor");
|
"Open magnet link with receptor");
|
||||||
|
|
Loading…
Reference in New Issue
Block a user