[英]webpack 2 hot reload not rerender
我正在開發Universal React項目,我的客戶端入口點是:
import React from 'react' import {render} from 'react-dom' import {Provider} from 'react-redux' import {AppContainer} from 'react-hot-loader' import {Router, browserHistory} from 'react-router' import {syncHistoryWithStore} from 'react-router-redux' import {addLocaleData} from 'react-intl' import it from 'react-intl/locale-data/it' import en from 'react-intl/locale-data/en' import IntlProvider from 'shared/containers/IntlProvider' import configureStore from 'shared/configureStore' import routes from 'shared/routes' import {isDev, isLive} from 'shared/config' [en, it].forEach(addLocaleData) const hook = document.getElementById('app') const initialState = JSON.parse(hook.getAttribute('data-initial-state')) const store = configureStore(initialState) const history = syncHistoryWithStore(browserHistory, store) let content = ( <Provider store={store}> <IntlProvider key="intl"> <Router history={history}> {routes} </Router> </IntlProvider> </Provider> ) if (isLive) { content = <AppContainer>{content}</AppContainer> } function renderApp() { render(content, hook) } if (isLive) { module.hot.accept('./index.js') module.hot.accept('../shared/routes', renderApp) } renderApp()
在組件更改時,重新加載似乎工作,但沒有應用渲染..也許它發生在熱重載技巧發生之前?
注意我的路線配置現在是經典的非動態路線。
我遇到了同樣的問題,因為我忘了為模塊替換添加代碼
if (module.hot) {
module.hot.accept(
"./App",
() => {
const NextApp = require("./App").App; // THIS LINE
render(NextApp);
},
);
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.