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 Connection from './ui/connection';
|
||||
|
||||
let skip_init = false;
|
||||
|
||||
export function initialize(uri) {
|
||||
if (skip_init) {
|
||||
skip_init = false;
|
||||
return;
|
||||
}
|
||||
store.dispatch(socket_uri(uri));
|
||||
store.dispatch(socket_update(SOCKET_STATE.CONNECTING));
|
||||
ws_init(uri, () => {
|
||||
|
@ -29,18 +35,29 @@ export function initialize(uri) {
|
|||
});
|
||||
}
|
||||
|
||||
const render = main =>
|
||||
ReactDOM.render(
|
||||
<Provider store={store}>
|
||||
<ConnectedRouter history={history}>
|
||||
<div>
|
||||
<Nav />
|
||||
<div className="container-fluid">
|
||||
<Main />
|
||||
{main}
|
||||
</div>
|
||||
</div>
|
||||
</ConnectedRouter>
|
||||
</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",
|
||||
window.location.origin + "/add-torrent/%s",
|
||||
"Open magnet link with receptor");
|
||||
|
|
Loading…
Reference in New Issue
Block a user