Need to restart computer when developping - react-native

I try to make apps in react native (not with expo, I created my code with react-native init and run with react-native run-android) and when I make changes in the code they are not always taken into account : to take them into account I have to restart computer.
I have to do it several times a day, it is time consuming. I have tested to remove to app tested from the device, to make yarn cache clean, but it doesn't work, the only thing that works is to restart (I am using a Mac if it makes a difference).
Is there a command I can make to reset a cache that I don't know and save previous state of my app ?

You may have a caching issue, try the cache clearing solutions in this link
How to clear react-native cache?
And also, you may want to try the Hot Reloading or Live Reloading options in the dev menu.
What is the difference between Hot Reloading and Live Reloading in React Native?

Related

My react native app with expo takes a long time to load

I developed an application in react native using expo and I have a problem, the app takes a long time on the splash screen before starting, I didn't use any method to make the splash visible for a longer time. The issue occurs in both the development version and the production version.
Another point is that I read in an article that IIFE functions should be avoided inside useEffect, and so I removed the ones I used but I still have the performance problem, does anyone have any ideas on how to improve?
If the connection is made but bundle building is very slow - Try disconnecting from the network both devices, and reconnect your system . Also, don't forget to clear the 'recently in development' projects, terminals and start the project again. It will increase the speed of building , especially for windows it works very well.

Why expo hot reload sometimes happend with no aparent reason?

Sometimes with no aparent reason the app gets refreshed, sometimes when i open a file. And when i add a library the expo development server crash, i think that maybe is something with watchman configuration that i don't know how to change. This is enoying.Any help?
PD: I'm using vscode
fast refresh will happen any time a file is changed in your project directory. if you have some other tools that run in that same directory and cause files to be changed then it could be happening seemingly randomly

Stuck on Downloading Javascript Bundle 100% - Expo

I guess that I've tried every solution that exists on the internet about this issue, and nothing works, and I don't even know where to look anymore. It started to happen from nowhere and I can't even open the app settings shaking the phone, it's completely stuck on this screen.
I cleaned up NPM, Yarn, Expo's caches and disabled the Remote Dev Tools.
I would be so much thankful for any help.
In my case it was due to the a remote debugger.
I left the remote debugging on, put the mac in sleep and when I turned it on again the iOS Simulator remained stuck at bundling 100%, irrespective of what I've tried (kill simulator, expo r -c, Reload app, etc.)
However, I could have realized the root cause earlier because on the physical device it was working the entire time.
Hope this saves someone some time.
You could try reverting to your last known working commit, then incrementally adding back the changes until this happens again. This often is a result of delaying hiding the splash screen (perhaps via AppLoading or SplashScreen) and then not hiding it because of some error in the app code preventing the code to hide it from being called.
Try Disable Debug Remote JS in the IOS Simulator
by clicking ctrl + cmd +Z on Mac
It works for me.
Seems like something is wrong with the dependencies, just close down the react-native environment ( android studio) and your IDE, just closing and restarting may work if not, check for updates or delete and reinstall your dependencies ( expo i )

React-native watchman doesn't work anymore

Few days ago I noticed watchman stopped working.
Using a real android device with shake gesture I cannot Reload the app (a reload doesn't take the changes to the code). Live reload and hot reloading don't work either.
The only way I have to get the app take the changes is to kill the packager and relaunch it (often neither this method makes the app takes changes!).
There is a way I can solve? This issue It's pretty frustrating.
I'll answer to myself. After further research, this issue looks to be caused by this option in app.json
"packagerOpts": {
"nonPersistent": "--nonPersistent"
}
which I've added to be able to produce a release build using Expo (otherwise I get error "socket hang up").
It would be nice if some Expo developer would post some infos about this issue and what that option in app.json really does (the docs says nothing).

Reactnative Fetching JS Bundle Serve Previous Bundle

I am on Windows.
Here are the specs
react-native-cli: 1.0.0
react-native: 0.32.0
Starting react-native using
react-native start
it will take upto 3-4 mins to start serving JS bundle, but after initial run it won't detect changes made in different files.
Reloading the bundle from device or simulator always return the bundle of the first run. I've to kill and restart the react-native.
It was happening now frequently, previously it only happens if the react-native has been started and stayed idle for sometime.
If your changing only JS file and you want to see changes immediately, enable hot/live reloading. Note this works only for development build, if your doing production build you should use Codepush.
react-native's runing command has upgraded for a while, and it uses caches to run faster,but it also cause a problem that cache is not cleaned after you change your code.so sometimes(may be always),it's runing the cache.
my solution is cacel the runinng process, and restart react-native.
ctrl+C & react-native start
looking for a better solution.