Mars
Mars

Reputation: 936

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

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?

Upvotes: 8

Views: 4302

Answers (2)

DannyMoshe
DannyMoshe

Reputation: 6265

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)

Upvotes: 1

Anita
Anita

Reputation: 3166

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.

Upvotes: 3

Related Questions