0

I want to learn React. so I installed Nodejs(v 10.16.0 LTS) and then using Windows Powershell I run following commands

npx create-react-app my-app
cd my-app
npm start

After installing, When I try to make a change in any code (like changing page title name), after saving code file. The Tab in Browser does not reload automatically and when I reload tab manually the error occurs which say

This site can’t be reached

localhost refused to connect.

Try:

Checking the connection

Checking the proxy and the firewall.

If I start this using PowerShell using npm start* command, then it run successfully. but I have to do this every time even when I edit my code. Browser tab did not reload and apply changes automatically.

Kindly guide me about this issue. Thanks

Umair Janjua
  • 324
  • 1
  • 2
  • 11

2 Answers2

0

you need to add react-hot-loader in your project react doesn't come with hot reload you need to include it in your project below is the link to npm please go through the documentation they provide once, and add it in your project.

techipank
  • 432
  • 4
  • 17
0

You shouldn't need react-hot-loader or anything else if you've created your react app through create-react-app - just make sure you're using the latest stable version of create-react-app

In your react app, when you run npm start, it uses react-scripts start script which behind the scenes uses webpack which actually takes care of hot module replacement

The problem you're facing seems most likely related to your local setup. Can you try running your app on a different port 8080 maybe?

Secondly, hot module replacement uses a websocket connection, can you check in your console if there is any error related to ws connection?

Saad Rashid
  • 91
  • 1
  • 5