Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to react-native run in debug mode immediately

Tags:

react-native

I'm always running react-native run-ios, I tend to reset the emulator content and settings from time to time for regression purposes.

In order to go into debug mode, we have to CMD+D > Debug mode, but is there a command option so that the debugging mode is enabled right after react-native run-ios (fresh install) command?

Closest question I've found is https://stackoverflow.com/a/41345139/1405577 but it does not work

$ react-native run-ios --install-debug
error: unknown option \`--install-debug'
like image 403
mjabadilla Avatar asked Nov 09 '17 06:11

mjabadilla


People also ask

How do I run React Native in debug mode?

In App Developer MenuOn 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.

How do I enable debugging in react?

There are two main ways in which we can use them: By writing the debugger statement in our source code. By clicking on a specific line of the code in the Chrome web browser (or Firefox, Edge, etc.) Developer Tools.

How do I debug React Native in Visual Studio?

Click the Add Configuration button that shows up when you open the file, then click on React Native. This will bring up another menu that will ask you what kind of debugging configuration you want to create. Choose Debug application.


1 Answers

You can do it with setIsDebuggingRemotelyfrom NativeModules:

import { NativeModules } from 'react-native';

if (__DEV__) {
  NativeModules.DevSettings.setIsDebuggingRemotely(true)
}

Then Debug JS Remotely will be activated on start.

like image 92
NEOline Avatar answered Sep 29 '22 16:09

NEOline