Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fast Refresh #9913

Closed
perinazzoo opened this issue Oct 26, 2020 · 18 comments · Fixed by #11105
Closed

Fast Refresh #9913

perinazzoo opened this issue Oct 26, 2020 · 18 comments · Fixed by #11105

Comments

@perinazzoo
Copy link

Now, fast refresh is enabled by default on CRA, but is there any way to turn this off and use hot reload instead?

@obsius
Copy link

obsius commented Oct 26, 2020

I set FAST_REFRESH=false as an env var. This didn't work, but when I changed:

    // from
    const hasReactRefresh = process.env.FAST_REFRESH !== 'false';

    // to
    const hasReactRefresh = process.env.FAST_REFRESH !== false;

on line 246 of react-dev-utils\webpackHotDevClient.js it worked.

@faouzioudouh
Copy link

@obsius so you can set FAST_REFRESH='false'
And then you don't have to change anything else.

@obsius
Copy link

obsius commented Oct 26, 2020

@faouzioudouh

That didn't work for me, it's always a boolean by that point, probably because of this:

        // Whether or not react-refresh is enabled.
        // react-refresh is not 100% stable at this time,
        // which is why it's disabled by default.
        // It is defined here so it is available in the webpackHotDevClient.
        FAST_REFRESH: process.env.FAST_REFRESH !== 'false',

in config/env.js.

@RosenTomov
Copy link

RosenTomov commented Oct 26, 2020

I'm having trouble refreshing the app at all, adding and removing components does nothing, only the styles update when changed.
I tried passing false, but it didn't help. Didn't they replace hot reload entirely with fast refresh?

Edit:
Adding

    [
      "react-app",
      {
        "runtime": "automatic"
      }
    ]

in babel presets, solved the issue. Now the app reloads properly.

@martinfrancois
Copy link

@perinazzoo I don't know why so many people believe it's enabled by default, in fact fast refresh is NOT enabled by default!
See here:

// which is why it's disabled by default.

@obsius
Copy link

obsius commented Oct 26, 2020

@martinfrancois

The comment might say that, but if I don't set FAST_REFRESH as an env variable, it ends up as undefined which evaluates in that line to true.

@martinfrancois
Copy link

@obsius so that's a bug then?

@obsius
Copy link

obsius commented Oct 27, 2020

@martinfrancois

Perhaps, else the comment is outdated?

@n3tr
Copy link
Contributor

n3tr commented Oct 27, 2020

@martinfrancois

Perhaps, else the comment is outdated?

Yes, the comment is probably outdated (per #9350)

@jbaileyashe
Copy link

Edit:
Adding

    [
      "react-app",
      {
        "runtime": "automatic"
      }
    ]

in babel presets, solved the issue. Now the app reloads properly.

@RosenTomov when you say 'babel presets', what file are referring to? I'd like to try this fix myself.

@lkarmelo
Copy link

When i update App.tsx component code, it usually updates page with latest changes, but sometimes it doesn't. When i change css, it picks up update nicely. But when i change any code oitside of css or components, browser console displays all new warnings, indicating it receiver new code, but the page doesn't reload and changes don't apply. In all cases code recompiles, so it's not watcher problem.

@dwiyatci
Copy link

When i update App.tsx component code, it usually updates page with latest changes, but sometimes it doesn't. When i change css, it picks up update nicely. But when i change any code oitside of css or components, browser console displays all new warnings, indicating it receiver new code, but the page doesn't reload and changes don't apply. In all cases code recompiles, so it's not watcher problem.

👆 Second this. Pretty much the same issue here 😕

@osadchiynikita
Copy link

osadchiynikita commented Nov 2, 2020

+1 setting FAST_REFRESH=false to the .env doesn't help

In addition: Fast Refresh re/compilation time in CRA 4 TS 4 project is very very very slow...

UPD. It's slow due to eslint cache missing in webpack dev config, should be fixed in the CRA 4.0.1 - https://github.com/facebook/create-react-app/milestone/78

@redders6600
Copy link

Same issue as @lkarmelo and @dwiyatci - did either of you find a workaround for this?

@dwiyatci
Copy link

dwiyatci commented Dec 1, 2020

@redders6600 Yes, I rolled back to v3.4.4 haha. But I guess you could as well try this now: https://github.com/facebook/create-react-app/releases/tag/v4.0.1 by setting FAST_REFRESH=false.

@lkarmelo
Copy link

lkarmelo commented Dec 1, 2020

@redders6600 They released react-scripts version 4.0.1 recently and fixed issue, now FAST_REFRESH=false works

@raghavsurya
Copy link

Doesn't work for me even with FAST_REFRESH=false in .env file :(

@rodrigocode4
Copy link

This is a problem with inotify, which observes file system events, individual files or directories, in linux of course.

The help would be:

  1. insert the new value into the system config
    echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

  2. check that the new value was applied
    cat /proc/sys/fs/inotify/max_user_watches

  3. config variable name (not runnable)
    fs.inotify.max_user_watches=524288

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.