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 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,17 +35,28 @@ export function initialize(uri) {
|
|||
});
|
||||
}
|
||||
|
||||
ReactDOM.render(
|
||||
<Provider store={store}>
|
||||
<ConnectedRouter history={history}>
|
||||
<div>
|
||||
<Nav />
|
||||
<div className="container-fluid">
|
||||
<Main />
|
||||
const render = main =>
|
||||
ReactDOM.render(
|
||||
<Provider store={store}>
|
||||
<ConnectedRouter history={history}>
|
||||
<div>
|
||||
<Nav />
|
||||
<div className="container-fluid">
|
||||
{main}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</ConnectedRouter>
|
||||
</Provider>, document.getElementById('root'));
|
||||
</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",
|
||||
|
|
Loading…
Reference in New Issue
Block a user