React-native projects are refreshing on their own when switching between files in Vscode editor

1.1k views Asked by At

For some time now, when im running my react-native projects in vscode and I switch between files in the editor, the project fast refreshes on its own, without me pressing ctrl+s. This will only happen when the file I switch to inside the editor has not been opened before during the session. I have done some research that suggested there might be a cloud service storing/syncing the files. But that doesnt seem to be the case because i have already checked my Google drive and nothing from my projects are there.. have never opened dropBox before, and I dont have an iCloud account on this windows PC. Furthermore I have tried deleting the project and recloning it with no luck... this is a very annoying issue since sometimes I will be working on a screen deep inside navigation and if I open a file I haven't recently used it will take me all the way back to home screen. I suspect vscode is causing the problem, or maybe my file explorer is messed up.. any suggestions on what I should try? (running windows 10)

2

There are 2 answers

0
Squirrel On BEST ANSWER

I wanted to add this as a comment, but I lack the reputation. I experienced this recently after upgrading to the latest React Native version. I noticed that this doesn't just apply to VS Code; any file editor (Notepad++ or the default Win. notepad) would trigger a reload but only while the Metro server was running.

Solution: Append --reset-cache when starting your metro server. E.g.

react-native start --reset-cache 
npm start -- --reset-cache` // alternative if you use npm or yarn

You're golden if it says "warning: the transform cache was reset." in the terminal.

0
404.html On

What worked for me was installing Watchman:

https://facebook.github.io/watchman/docs/install.html

I found this solution on Reddit.