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

Ubuntu basic settings: installation and use of openssh-server

Record the installation and use of openssh-server...

HTML 5.1 learning: 14 new features and application examples

Preface As we all know, HTML5 belongs to the Worl...

Detailed tutorial on installing Python 3 virtual environment in Ubuntu 20.04

The following are all performed on my virtual mac...

Nginx dynamically forwards to upstream according to the path in the URL

In Nginx, there are some advanced scenarios where...

Mysql splits string into array through stored procedure

To split a string into an array, you need to use ...

How to reset the root password in mysql8.0.12

After installing the database, if you accidentall...

Practical record of handling MySQL automatic shutdown problems

I recently helped someone with a project and the ...

HTML+CSS merge table border sample code

When we add borders to table and td tags, double ...

Solution for applying CSS3 transforms to background images

CSS transformations, while cool, have not yet bee...

HTML markup language - reference

Click here to return to the 123WORDPRESS.COM HTML ...

What are inline elements and block elements?

1. Inline elements only occupy the width of the co...

Vue realizes screen adaptation of large screen pages

This article shares the specific code of Vue to a...