question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Hot Reload stopped working with React "^17.0.1"

See original GitHub issue

Describe the bug

Hot reloading when the redux-state change stopped working when I use CRA to get the last React version. Noticed that it is due to React version and I made a test creating a new react project, as a result the package.json shows

"dependencies": {
    "@testing-library/jest-dom": "^5.11.5",
    "@testing-library/react": "^11.1.0",
    "@testing-library/user-event": "^12.1.10",
    "react": "^17.0.1",
    "react-dom": "^17.0.1",
    "react-redux": "^7.2.1",
    "react-scripts": "4.0.0",
    "redux": "^4.0.5",
    "web-vitals": "^0.2.4"
  },

then change it to a previous version of react (copied from an old project)

"dependencies": {
    "@testing-library/jest-dom": "^4.2.4",
    "@testing-library/react": "^9.5.0",
    "@testing-library/user-event": "^7.2.1",
    "react": "^16.13.1",
    "react-dom": "^16.13.1",
    "react-redux": "^7.2.1",
    "react-scripts": "3.4.3",
    "redux": "^4.0.5"
  },

And it continue to works as always.

Did you try recovering your dependencies?

yes

Environment

current version of create-react-app: 4.0.0 running from C:\Users\stewa\AppData\Roaming\npm\node_modules\create-react-app

System: OS: Windows 10 10.0.19041 Binaries: Node: 12.9.1 - C:\Program Files\nodejs\node.EXE Yarn: Not Found npm: 6.14.8 - C:\Program Files\nodejs\npm.CMD Browsers: Chrome: 86.0.4240.111 Edge: Spartan (44.19041.423.0), Chromium (86.0.622.51)
Internet Explorer: 11.0.19041.1 npmPackages: react: ^17.0.1 => 17.0.1 react-dom: ^17.0.1 => 17.0.1 react-scripts: 4.0.0 => 4.0.0 npmGlobalPackages: create-react-app: Not Found

Steps to reproduce

(Write your steps here:)

  1. I have a file with a state with this value in my Redux reducer
const initialState = [
  {
    id: Date.now(),
    task: "new todo ",
    completed: false,
  }
];
  1. Modify the object in the file to this
const initialState = [
  {
    id: 1,
    task: "new todo ",
    completed: false,
  },
  {
    id:123,
    task: "new todo ",
    completed: false,
  }
];
  1. As previous versions of React / CRA the page force a reload, displaying in the page the new object added, but it’s not anymore

Expected behavior

Even if you change the text of one of the objects in the reducer it used to reload the page. I’m expecting to see the new state in the page as I save a file when the state change

Actual behavior

alt text

Here you can see I saved the file and the page is not showing the new state, and the new data.

Reproducible demo

https://github.com/StewartGF/todo-test

I created this clean project with CRA, it has react v17 You can change the version in the package.json to what I paste in the description and use npm install in order to see the project working as it was working in previous versions.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:96
  • Comments:115 (3 by maintainers)

github_iconTop GitHub Comments

80reactions
fast-reflexescommented, Nov 28, 2020

I am not sure everyone is having the same problem.

For me, when i have nothing on .env or FAST_REFRESH=true, i will get the fast refreshes for components change, but other files changes will not reload the page, despite my console showing that it recompiled.

When i have FAST_FRESH=false, everything is hot-reloading and everything works.

Worked! With React 17.0.1 and react-scripts 4.0.0 and with FAST_REFRESH=true (default) changes to components are reflected seemlessly, but changes to other dependencies are not reflected in the UI at all without manual refresh, despite obvious recompilation in the console. Setting the flag to false in .env didn’t change anything but when I updated to react-scripts 4.0.1 setting FAST_REFRESH=false in .env brought back the hot reload.

73reactions
FezVrastacommented, Oct 26, 2020

fast refresh is enabled by default.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Hot Reload is not working in my React App - Stack Overflow
Hot Reload is not working in my React App · This does happen sometimes. Do npm install and try adding some code. ·...
Read more >
Hot Reload not working in React 17.0.3 - Code with Mosh Forum
Hi, I have recently created a new project with create-react-app. Also, I am following Mosh's Mastering React course and according to it, ...
Read more >
[Solved]-Hot Reload is not working in my React App-Reactjs
There is a hot reloading issue for some browsers, with react version 17. Below is the simplest way to fix this: Go to...
Read more >
Getting Started · React Hot Loader - Dan gaearon
If hot reloading doesnʼt work, itʼs usually due to a deviation from the configuration described above. Make sure to compare your setup to...
Read more >
react-hot-loader - npm
React Native supports hot reloading natively as of version 0.22. Using React Hot Loader with React Native can cause unexpected issues (see #824) ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found