Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

react-native how to debug on device with wifi/data off?

Tags:

react-native

it tries to connect to npm server and throws red screen, I want to test some offline on-load features.

or is there someway to debug without npm server?

like image 942
Mars Avatar asked Mar 19 '18 04:03

Mars


2 Answers

To debug offline IOS (react native) you can run two commands: - once you turned off your wifi, run this command in the terminal:

sudo ifconfig lo0 alias 192.xx.xx.xx - 192.xx.xx.xx is your ip address (you can get the ip address running ifconfig command)

After running above command and being offline you should not have the red screen

To undo the above command you run:

sudo ifconfig lo0 -alias 192.xx.xx.xx, being still offline you will get now the red screen.

Hope this helps.

like image 152
Anita Avatar answered Sep 19 '22 08:09

Anita


To debug on an android device (usb connected) you need to do the following:

  1. Enable USB debugging on your android device

  2. Navigate to your AndroidDevelopment/SDKManagerForAndroidStudio/Platform-tools/ directory in a terminal and type adb devices (this should pull up your connected device)

  3. Again in the terminal type adb reverse tcp:8081 tcp:8081

You should then be able to debug on your device. Here is a link to the docs (I think they explain how to go about this on ios, I've only tried it on Android)

like image 31
DannyMoshe Avatar answered Sep 18 '22 08:09

DannyMoshe