In lesson 9 of RN parts 2, mosh turns off his wifi to check cached data. When i turn off my wifi, expo goes offline and i get this message:
I ran into the same problem. I created a forum topic titled “React Native Advanced - caching with Async Storage - Tip” – did you take a look at that? That worked for me.
Similar problem. I disabled wifi connection through “REact Native Debuger”. And I can’t upload the AppNavigator component.
Code the same as Mosh with this one difference that imported AsyncStorage from “@react-native-async-storage/async-storage”. Also, I have PC, and I check it on Andriod, but I’m don’t think it is an issue.
The previous one was deprecated.
You are just talking about library changes. This forum topic is different. This is about lesson 9 in part 2
Hello. Have you found a solution?
Yes, I have the same issue.
But additionally I have some funny thing. To emulate losing of connection I just turn off my backend server. Everything works pretty as expected, application tries to reach server, finally fails and download cache using AsyncStorage. But somehow I still able to see images I can’t reach them using url, because obviously server is turned off, but Android emulator which I use saves them somewhere in its cache and uses them.
Couple things to keep in mind here:
Testing this on a device doesn’t work - I tried on iPhone - turned off wifi - shut down the data server and everything produced a connection error.
I tried it on Android emulator and shutting down the wifi as Mosh suggests does not work but shutting down data server make images disappear as mentioned in the lesson.
However, keep in mind that first couple of images will still show. I believe that is the Android cache in action. If you scroll down, on the rest of the items, there are no images on the listed items as expected.
Hope this helps.
when I turned my wifi off the metro disconnected and doesn’t work as expected
The way to do this properly is install a proxy on the machine that you run expo on, and then use the proxy ip and port in your device’s wifi settings. Then every single request will go through your computer, and will go offline if you disable it. I use Proxyman, which used to be mac only but now has a windows version https://proxyman.io/
The other advantage of doing this is that you can install the proxy’s CA cert on your phone, meaning that whilst developing you can use a self signed SSL certificate (more info here Using self signed certificates in a React Native project – DelBoys Place).