How to debug react native apps in visual studio code?
If you want to debug the app in VS Code itself, like in other IDEs. Then on approach can be to follow the following steps:
- Install
React Native Tools
Extension (provided byMicrosoft
) to VS Code.
This is a nice add on to VS Code's capabilities for React Native.
- Then go to Debug option from left menu and click on Add Configuration.
If it initially says No Configuration
then you can click on Add Configuration and then choose React Native option.
- Now if already have
Launch configuration
added, then you can click on Add Configuration button then you will see more options related to React Native.
You can add configurations for React Native: Attach to Packager
, React Native: Debug to Android
, React Native: Debug to iOS
in your launch.json
file. It is present in .vscode
folder.
- Then add your breakpoints in code. Now suppose you already have your app running on emulator then you can choose option
Attach to Packager
.
- Then on emulator or device open developer options (Ctrl + M for Windows + Android) and click on
Debug JS Remotely
.
Now your breakpoints should be working. Similarly if your app wasn't working already then you can go for Debug Android
or Debug iOS
accordingly.