Try   HackMD

React Native 兩種開發專案類型

tags: React Native Tutorial

React Native 有 2 種方式,可選擇其中一種開發方式

  1. Expo
  2. React Native CLI

Expo

無需設定環境即可開發雙平台的架構,Exop 已經安裝好執行環境,可以免除建置開發 Android 跟 iOS 環境的需求,非常方便學習及練習用,但相對的缺點就是如果用 Expo 開發時,若要針對 Native 去撰寫一些客製化的功能可能會比較麻煩。

因次建議初學者可以使用 Expo 學習 React Native 的開發方式,或是評估目標 APP 只會使用到簡單的功能都有包含在 Exop SDK 下。

因為 Expo Build 的時候是使用 EAS 的建立方式,不是根據 Android 與 iOS 原生的建置方式。

npx create-expo-app AwesomeProject!

  • cd AwesomeProject
  • npm run android
  • npm run ios
  • npm run web

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

React Native CLI

可以很彈性的使用 React Native 去開發,也可以針對各平台的 Native code 去客製化撰寫,但是需要事先建立好個別的開發環境( 例如 Android / iOS )。

npx react-native init ReactNativeDemo

  1. cd ReactNativeDemo
  2. npx react-native start
  3. npx react-native run-android
  4. npx react-native run-ios

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

本教學文章是以 RN CLI 為教學內容做說明。