webpack.js.org icon indicating copy to clipboard operation
webpack.js.org copied to clipboard

React Hot MD guide app configuration won't hot reload

Open timurtu opened this issue 9 years ago • 6 comments

After following the steps of the React HMR guide I am left with an app that won't hot reload.

What happens is on every file change of the App.js the browser does reload, and it seems from the webpack-dev-server log as if the module rebundles, but nothing happens.

[HMR] Waiting for update signal from WDS... does print to the browser console although no changes are seen in the browser. The only way I've been getting app changes to register with this config is if I manually run webpack.

What should the index.html look like?

timurtu avatar Dec 19 '16 18:12 timurtu

I also have an issue with this guide, I'm getting an You may need an appropriate loader to handle this file type. error for my index.js for some reason.

macbem avatar Dec 24 '16 22:12 macbem

@timurtu @macbem

I ran through the React HMR guide and it ran fine on my local. I'm running:

  • ubuntu 16.04 LTS
  • node v6.1.0
  • npm v4.0.5
  • "devDependencies": { "babel": "^6.5.2", "babel-core": "^6.13.2", "babel-loader": "^6.2.4", "babel-preset-es2015": "^6.13.2", "babel-preset-react": "^6.11.1", "babel-preset-stage-2": "^6.13.0", "css-loader": "^0.23.1", "postcss-loader": "^0.9.1", "react-hot-loader": "^3.0.0-beta.6", "style-loader": "^0.13.1", "webpack": "^2.1.0-beta.25", "webpack-dev-server": "^2.1.0-beta.0" }
  • "dependencies": { "react": "^15.3.0", "react-dom": "^15.3.0" }

After reading the Guide, I was able to produce this in my browser:

Initial Load of index.html after setting up webpack+react+babel

hmr-react-1


index.html after changing text in /src/components/App.js (HMR works)

hmr-react-2

Perhaps a couple of steps needed more clarification. I created a PR to update the Guide. Hopefully this helps.

chrisVillanueva avatar Jan 08 '17 08:01 chrisVillanueva

You ran the HMR guide, because my PR with fixes has already been merged to the docs - sorry, I forgot to mention it here.

macbem avatar Jan 08 '17 11:01 macbem

What were the fixes?

timurtu avatar Jan 09 '17 00:01 timurtu

I have changed the required Webpack version.

macbem avatar Jan 09 '17 08:01 macbem

I tried the guide again and ran into a small issue, and that was destructuring resolve from path in the webpack.config.js. const { resolve } = require('path')

I'm not sure which node version has destructuring, I'm running v4.6.1, but after changing it to a normal require statement everything seems to be working.

timurtu avatar Jan 17 '17 15:01 timurtu