React Native mobile development practices-2-how to debug the React Native project-2-react

Source: Internet
Author: User

React Native mobile development practices-2-how to debug the React Native project-2-react

In actual development, there is also an important factor that affects development efficiency: debugging.

The use of Enable Live Debugger is introduced in Section 1.4.3. This section describes another important debugging option: Debug JSRemotely.

(1) Shake the device or use the keyboard shortcut on the simulator (iOS simulator shortcut: command + d, Android simulator shortcut: command + m) to open the debugging option, as shown in Figure 2.15.

 

Figure 2.15 React Native debugging options

(2) Click the Debug JS Remotely option. In this case, React Native automatically opens the Chrome browser as a debugging tool.

(3) perform operations in the order shown in 2.16, so that the debugging status of the React Native application is entered.

 

Figure 2.16 use Chrome to debug the ReactNative Application

(4) In the debugging status, click the number of lines in row 12th of the index. ios. js file to add a breakpoint, as shown in Figure 2.17.

[Question] What is a breakpoint in software development?

[Answer] resumable point is one of the functions of the debugger. When a Breakpoint is set during debugging, the program can be stopped when it runs the program. In this way, when the program reaches the Breakpoint, its variables, latches, I/O, and other related variables help you gain an in-depth understanding of program operation mechanisms and discover and eliminate the root cause of program errors.

 

Figure 2.17 Add a breakpoint during React Native debugging

(5) Finally, reload the running application (the iOS simulator shortcut key is command + r, and the Android simulator shortcut key is r + r ). At this point, the application stops running to the 12th line that just added the breakpoint, as shown in Figure 2.18.

 

Figure 2.18 paused at the breakpoint during React Native debugging

At this point, you can view the information in the debugging area on the right: the thread status (Threads), variable value, Call Stack, and other information of the current application execution. In addition, you can use commands at the top of the debugging area to perform single-step execution, skip execution, and continue execution, as shown in Figure 2.19.

 

Figure 2.19 Debugging commands for React Native debugging

Debugging skills and experience need to be accumulated continuously during the development process. After mastering these basic usage, you can continue to practice and accumulate development experience through the following examples, improve debugging capability and development efficiency.

 

Learn With Me, React Native mobile development practices

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.