I'm trying to add some offline support for my app, but debugging the app with my emulator in airplane mode seems to be a giant pain. Every time I reload the app without a connection I am met with this:
So, in essence, I would like to have the app think it does not have a connection, but maintain the connection to my development server. Is that possible?
First, you need to check to internet connection, to make sure the device is online or offline. For this, you can use this library @react-native-community/netinfo. Second, you need to store the question and answer on redux, so when the device is offline, you can load the question from redux.
The most popular methods to achieve offline support in React Native are by implementing usage restrictions, caching, and request queuing.
In App Developer Menu On Android emulator, you need to press command + M. Debug JS Remotely − Used for activating debugging inside browser developer console. Enable Live Reload − Used for enabling live reloading whenever your code is saved. The debugger will open at localhost:8081/debugger-ui.
The problem is 10.0.3.2
is being provided by your router so when you are on offline (or without connection), who is going to route that ip?
One option to solve this problem is to use localhost
or 127.0.0.1
as Debug Server.
Other option could be adding in your host (c:\C:\Windows\System32\drivers\etc) a traduction for your IP, something like this:
10.0.3.2 127.0.0.1
Of course you have to change your devs settings in your emulator
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With