React + Webpack HMR is refreshing the page (not hot loading) React + Webpack HMR is refreshing the page (not hot loading) reactjs reactjs

React + Webpack HMR is refreshing the page (not hot loading)


I just ran into this problem. A couple things:

To help debug your particular issue, try enabling "Preserve log" (in Chrome dev tools). This will persist console logs across page refreshes, so you'll at least be able to see any messages that webpack-dev-server is logging before it triggers a refresh.

"Preserve log" option in Chrome devtools

In my case webpack-dev-server was refreshing because I had not opted into HMR in my entry js file. Adding the following line to the file solved the issue:

// Opt-in to Webpack hot module replacementif (module.hot) module.hot.accept()

For details on the module.hot API the webpack HMR docs are very helpful.