Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
697 views
in Technique[技术] by (71.8m points)

reactjs - How to debug react native apps in visual studio code?

I am using visual studio code IDE to develop react native app and am not using expo library.

Before that I was working on the android studio, debugging in that is straightforward and simple.

Now for react-native, I wanted to know how to debug my app using visual studio code IDE?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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:

  1. Install React Native Tools Extension (provided by Microsoft) to VS Code.

enter image description here

This is a nice add on to VS Code's capabilities for React Native.

  1. Then go to Debug option from left menu and click on Add Configuration.

enter image description here

If it initially says No Configuration then you can click on Add Configuration and then choose React Native option.

  1. 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.

enter image description here

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.

  1. Then add your breakpoints in code. Now suppose you already have your app running on emulator then you can choose option Attach to Packager.

enter image description here

  1. Then on emulator or device open developer options (Ctrl + M for Windows + Android) and click on Debug JS Remotely.

enter image description here

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...