mirror of
https://github.com/woodchen-ink/clash-and-dashboard.git
synced 2025-07-18 14:01:56 +08:00
Improve: hot reload
This commit is contained in:
parent
1a202dea98
commit
26541f22fc
@ -1,5 +1,6 @@
|
||||
import * as React from 'react'
|
||||
import { Route } from 'react-router-dom'
|
||||
import { hot } from 'react-hot-loader'
|
||||
import { I18nProps } from '@i18n'
|
||||
import './App.scss'
|
||||
|
||||
@ -13,6 +14,7 @@ import SlideBar from '@containers/Sidebar'
|
||||
export interface AppProps extends I18nProps {
|
||||
}
|
||||
|
||||
@hot(module)
|
||||
export default class App extends React.Component<AppProps, {}> {
|
||||
render () {
|
||||
const routes = [
|
||||
|
@ -24,7 +24,6 @@ OfflinePluginRuntime.install({
|
||||
// Reload the webpage to load into the new version
|
||||
window.location.reload()
|
||||
},
|
||||
|
||||
onUpdateFailed: () => {
|
||||
console.error('SW Event:', 'onUpdateFailed')
|
||||
}
|
||||
|
@ -3,45 +3,21 @@ import { render } from 'react-dom'
|
||||
import { Provider } from 'mobx-react'
|
||||
import { HashRouter } from 'react-router-dom'
|
||||
import { I18nextProvider } from 'react-i18next'
|
||||
import { AppContainer } from 'react-hot-loader'
|
||||
import { rootStores } from '@lib/createStore'
|
||||
import App from '@containers/App'
|
||||
import i18n from '@i18n'
|
||||
|
||||
const rootEl = document.getElementById('root')
|
||||
|
||||
// Hot Module Replacement API
|
||||
declare let module: { hot: any }
|
||||
|
||||
export default function renderApp () {
|
||||
render(
|
||||
<AppContainer>
|
||||
<Provider {...rootStores}>
|
||||
<HashRouter>
|
||||
<I18nextProvider i18n={ i18n }>
|
||||
<App />
|
||||
</I18nextProvider>
|
||||
</HashRouter>
|
||||
</Provider>
|
||||
</AppContainer>,
|
||||
rootEl
|
||||
const rootEl = document.getElementById('root')
|
||||
const AppInstance = (
|
||||
<Provider {...rootStores}>
|
||||
<HashRouter>
|
||||
<I18nextProvider i18n={ i18n }>
|
||||
<App />
|
||||
</I18nextProvider>
|
||||
</HashRouter>
|
||||
</Provider>
|
||||
)
|
||||
|
||||
if (module.hot) {
|
||||
module.hot.accept('./containers/App', () => {
|
||||
const NewApp = require('./containers/App').default
|
||||
render(
|
||||
<AppContainer>
|
||||
<Provider {...rootStores}>
|
||||
<HashRouter>
|
||||
<I18nextProvider i18n={ i18n }>
|
||||
<NewApp />
|
||||
</I18nextProvider>
|
||||
</HashRouter>
|
||||
</Provider>
|
||||
</AppContainer>,
|
||||
rootEl
|
||||
)
|
||||
})
|
||||
}
|
||||
render(AppInstance, rootEl)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user