The React Native notes

Vscode plug-in

  • Prettier – Code formatter
  • React Native Snippet

React Native Basic commands

Adb shell input keyevent 82 # React Native scaffold NPM install -g React Native cli NPX React-native run-Android init your-app CD AwesomeProject Yarn Android # or Yarn React-native run-Android # Adb DevicesCopy the code

tip

Modify the entry file index.js

  • View netWork requests in netWork

GLOBAL. OriginalXMLHttpRequest reference XHR copy of Chrome development tools. Provided by RN as an escape hatch. Shvetusya’s solution works only if the development tool is open and provides XMLHttpRequest.

GLOBAL.XMLHttpRequest = GLOBAL.originalXMLHttpRequest || GLOBAL.XMLHttpRequest;

Copy the code
  • Disable yellow warning
Console. ignoredYellowBox = ['Warning: BackAndroid is deprecated. Please use BackHandler instead.','source.uri should not be an empty string','Invalid props.style key']; Console. disableYellowBox = true // Disable all yellow alertsCopy the code

Common Components

www.jianshu.com/p/53ff78168…

Reactnative. Dev/docs/more – r…

Design px unit converted to mobile phone DP

  • The formula

Design width/element width = width of the phone screen/width of the elements in the phone

The width of the element in the phone = the width of the phone screen * the width of the element/the width of the design

Genymotion error

React-native 错 误 : Unable to load script.Make sure you’re either running a Metro server or that…

react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res 

Copy the code

Packaging APK

Packaging APK keytool error: Java. IO. FileNotFoundException: MyAndroidKey. Keystore (access denied).

.\keytool -genkeypair -v -keystore d:/social_app.keystore -alias my-key-alias -keyalg RSA -keysize 2048 -validity 10000

Copy the code
  • Warning: The JKS keystore is in a proprietary format. You are advised to run keytool -importkeystore -srckeystore d:/my-release-key.keystore -destkeystore d:/my-release-key.keystore – deststoreType pkCS12 “Migrates to the industry-standard pkCS12 format.

Cause of the React Native Component ExceptionElement error

  • Do not add {} when importing components

  • reference

React Native Component Exception – Element Type is invalid: Expected String… got undefined