score:21

Accepted answer
  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.

score:1

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

score:1

you should first enable the debugging on for your simulator(ios)/emulator(android)

android: first enable the debugging on by pressing cmd+m here one popup will appear then click on debug , it will enable debugging on for that simulator device.

enter image description here

ios: click cmd+d, popup will appear click on debug same it will enable debugging for that simulator.

enter image description here

now run your applicationn on one of these virtual device(simulator/emulator), debugger ui will open in default browser tab(http://localhost:8081/debugger-ui/) now right click and click on inspect , it will open one window here you will get so many tabs, click on sources and find the file on which you want to debug the code. and here add break point by simply clicking on left side line number like below. here your app will debug and you can see what is happening with the code.

enter image description here

score:2

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


Related Query

More Query from same tag