React-native Fast Refresh broken

Viewed 3164

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

3 Answers

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

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.

Related