Reputation: 5306
recently my Fast Refresh stopped working across ALL of my react native projects, I have even tried init-ing a new project and it is not working there too
I have tried all the attempts below:
-. watchman watch-del-all
-. rm -rf /usr/local/var/run/watchman && brew uninstall watchman && brew install watchman
-. clean node_modules and "npm run -- --reset-cache"
Whatever way I try to reload the app after modifying the source code, the change will not get reflected. I have to stop and uninstall the app, run npm run -- --reset-cache
and then run npm run android
again in order to have the changes reflected.
This is really killing me as I can not find the cause of it. It was working before and I did not install any app on my machine. I am now short of formatting my machine and start everything from scratch again but this is a Mac and it is troublesome to reformat..
Upvotes: 5
Views: 12330
Reputation: 360
In my case the changes weren't reflected because I had the CI
environment variable set.
The Metro bundler is configured to turn off the watch mode in a CI environment.
So check if your environment is considered the CI one. You can do this by running
node -p "require('ci-info')"
This command will output a bunch of variables. You are interested in the isCI
variable. If it is true
, then check your environment variables and make sure you have removed the CI ones
...
XCODE_CLOUD: false,
XCODE_SERVER: false,
isCI: true
For more information see this issue
Upvotes: 0
Reputation: 792
It's not related to react-native, metro bundler, or sudo permission, It's because of .git/index.lock file!
Just remove it and everything would be OK.
Execute this command in the root directory of your project:
rm .git/index.lock
Upvotes: 9
Reputation: 962
This doesn't answer the question, but I'm leaving it for people who come here with a slightly different issue.
If after making a code edit, the app shows a message saying 'Refreshing...' but it fully reloads the app, then that means Fast Refresh and Hot Reloading is technically working. But for whatever reason, Fast Refresh is falling back to a full reload. To fix this, see this thread. Basically, name your default exports.
Upvotes: 2
Reputation: 1565
Have you tried ALL the solutions mentioned here? Seems like there're still a bunch that you haven't tried
https://github.com/facebook/react-native/issues/28420
I tried almost all and still not working, in desperation, the
sudo npx react-native start
solved my problem
https://github.com/facebook/react-native/issues/28420#issuecomment-755082770
Upvotes: 9