鍍金池/ 問答/HTML/ webpack-hot-middleware已經(jīng)實現(xiàn)了熱加載,但頁面不更新,需要

webpack-hot-middleware已經(jīng)實現(xiàn)了熱加載,但頁面不更新,需要手動刷新

webpack的入口配置了webpack-hot-middleware/client?path=/__webpack_hmr,
在頁面中熱更新正常

clipboard.png

圖片描述

但是更改了react里面的組件內(nèi)容,頁面就是不更新,需要手動刷新下。

回答
編輯回答
雨萌萌

入口js發(fā)出來看看,有沒有hot.accept()

2018年2月12日 06:31
編輯回答
枕邊人
const render = App => {
  ReactDOM.render((
    // <Provider store={store}>
    <App />
    // </Provider>
  ), document.getElementById('root'));
}

render(App)

if (module.hot) {
  module.hot.accept('./App', (App) => render(App))
}

在入口文件添加以上代碼

2017年11月18日 08:59