6

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..

5 Answers 5

9

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

Sign up to request clarification or add additional context in comments.

2 Comments

lifesaver!! only thing that worked was this! I can confirm as of 2024
Didn't fix it on MacOS and running without sudo afterwards becomes difficult without major cleanup. Thank you for sharing, but would not recommend this solution.
9

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

Comments

2

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.

Comments

0

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

Comments

0

I tried all the above without success. Plus to the fast refresh the console.log stopped sending messages to the metro terminal. I even tried to downgade my RN version – all the same.

Finally I found out the code that was causing the problem:

DeviceEventEmitter.removeAllListeners()

Commenting out the code resolved the issue in my case.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.