React Native scaffolding basic usage detailed explanation

React Native scaffolding basic usage detailed explanation

Build the project

Execute the command line in the corresponding path: react-native init 項目名(the name cannot use special characters such as hyphens, and the naming can refer to the APP application name such as FaceBook)

react-native --v //View the version react-native init demo --version 0.48.0 //Install the specified version react-native init demo --verbose --version 0.48.0 //verbose is used to display the installation details during initialization, including what modules are installed and the progress npm view react-native versions //You can view all version information of react-native

Jump to the corresponding path and execute the corresponding mobile project:

cd project name react-native run-ios or react-native run-android

If normal, the operation effect is as follows:

insert image description here

RN debugging tips

Developer Menu

Developer Menu is a developer menu customized by React Native for developers to help developers debug React Native applications.

Open the Developer Menu Android emulator on the emulator:

You can quickly open the Developer Menu using Command⌘ + M shortcut. It can also be opened using the menu key on the simulator.

iOS Simulator:

You can quickly open the Developer Menu using Command⌘ + D shortcut.

Reload

Refresh the page, the shortcut key is command + R.

Note: The refresh feature will only work if you modify the JavaScript file. If you add new files or modify the Native code, you need to recompile the application using Xcode .

Debug JS Remotely

This feature allows developers to debug applications in Chrome in the same way as they debug web applications.

change bundle location

Change the packaged address

toggle inspector

View component styles in the simulator. Not very useful.

disable fast refresh

Disable fast refresh

Show Perf Monitor

When this feature is enabled, a monitoring window will be displayed, showing real-time memory usage, UI and JavaScript FPS and other information. Helps us debug performance issues.

Errors and Warnings

In development mode, the Errors and Warnings of the js part will be printed directly on the phone or simulator screen, displayed in red and yellow screens. .

Errors

Errors that occur when the React Native program is running will be displayed directly on the screen, displayed with a red background, and the error message will be printed. You can also trigger Errors manually via console.error() .

insert image description here

Warnings

Warnings that appear when the React Native program is running will also be displayed directly on the screen, displayed with a yellow background, and warning messages will be printed out. You can also trigger Warnings manually via console.warn() . You can also manually disable the display of Warnings by console.disableYellowBox = true , or ignore the corresponding Warning by console.ignoredYellowBox = ['Warning: ...'];

Chrome Developer Tools

Step 1: Start remote debugging

Click "Debug JS Remotely" under the Developer Menu to start the JS remote debugging function. Chrome will be opened and a "http://localhost:8081/debugger-ui." Tab page will be created.

insert image description here

Step 2: Open Chrome Developer Tools

Open the developer tools under the "http://localhost:8081/debugger-ui." tab. Open the Chrome menu -> Select More Tools -> Select Developer Tools. You can also open the developer tools using the shortcut keys (Command⌘ + Option⌥ + I on Mac, Ctrl + Shift + I on Windows).

When some "inexplicable" problems and errors occur during breakpoint debugging, common solutions

The inexplicable here means that the code was still running normally at the last moment, and it became popular without modification:

1. Refresh! refresh! refresh!

2. Re-use the react-native run-xxx command to start the App

3. Delete the App, shut down the local server, and clear the local cache

yarn: clear cache yarn cache clean

npm: Clear the cache npm cache clean -f

This is the end of this article about the basic use of React Native scaffolding. For more relevant React Native scaffolding content, please search 123WORDPRESS.COM's previous articles or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • React Native react-navigation navigation usage details
  • ReactNative FlatList usage and pitfalls package summary
  • Specific usage of react-native fetch
  • Detailed explanation of the use of React native global variables (communication across components)
  • React-native example of using react-navigation for page jump navigation
  • Detailed explanation of the use of Modal in React-Native components
  • Detailed explanation of the use of ReactNative Image component

<<:  Use Navicate to connect to MySQL on Alibaba Cloud Server

>>:  VMware Workstation 14 Pro installation Ubuntu 16.04 tutorial

Recommend

How to set the width and height of html table cells

When making web pages, you often encounter the pr...

How to make vue long list load quickly

Table of contents background Main content 1. Comp...

Introduction and use of Javascript generator

What is a generator? A generator is some code tha...

How to optimize MySQL query speed

In the previous chapters, we introduced how to ch...

Detailed explanation of various join summaries of SQL

SQL Left Join, Right Join, Inner Join, and Natura...

Detailed explanation of replace into example in mysql

Detailed explanation of replace into example in m...

Docker builds CMS on-demand system with player function

Table of contents text 1. Prepare the machine 2. ...

Simple steps to create a MySQL container with Docker

Preface We have already installed Docker and have...

MySQL 20 high-performance architecture design principles (worth collecting)

Open Source Database Architecture Design Principl...

Detailed tutorial on installing nacos in docker and configuring the database

Environment Preparation Docker environment MySQL ...

Summary of Linux command methods to view used commands

There are many commands used in the system, so ho...

Introduction to generating Kubernetes certificates using OpenSSL

Kubernetes supports three types of authentication...

HTML basics - CSS style sheets, style attributes, format and layout details

1. position : fixed Locked position (relative to ...

jQuery plugin to achieve code rain effect

This article shares the specific code of the jQue...