Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to debug with breakpoints in React Native

Please help me how to debug in react native with breakpoints, I found only solution for android real devices, but unable to debug with android emulator and iOS simulator.

like image 682
Akhil Reddy Avatar asked Apr 01 '19 16:04

Akhil Reddy


3 Answers

  1. Install React Native Debugger tool
    • brew update && brew cask install react-native-debugger
    • brew cask reinstall react-native-debugger
  2. Quit Google Chrome if it already running.
  3. Launch the React Native Debugger app from Applications folder.
  4. Activate iOS simulator and Run command+d using keyboard. In the debug menu select “Debug JS Remotely” option.
  5. Go to React Native Debugger. Select ‘Toggle Developer Tools’ sub menu item from ‘View’ menu.
  6. Select Sources tab (in the React Native Debugger window).
  7. In the left side menu, expand RNDebuggerWorker.js and expand sub option localhost:****. You will see the project root folder.
  8. Select a .js file and add break point. Break point will get activated when the respective line is executed.
  9. You can see the console logs in the console area at the bottom.
like image 67
Praveen Matanam Avatar answered Oct 13 '22 19:10

Praveen Matanam


You can do it by adding breakpoints in your code lines on the source tab of chrome devTools, actually, there is no difference between Google Chrome devTools or React Native Debugger devTools, open the source and find RNDebuggerWorker.js in the left pane and you can find your codes and add breakpoints to debug line by line:

enter image description here

like image 34
AmerllicA Avatar answered Oct 13 '22 20:10

AmerllicA


You can do it by adding debugger; at the line in your code and Chrome will automatically stop at that line.

like image 26
fannolo Avatar answered Oct 13 '22 20:10

fannolo