blog.dopana

Back

React Native cho phép xây dựng iOS và Android từ một codebase JavaScript/TypeScript. Không phải “web view” — nó dùng native components thật.

React Native vs Flutter#

React NativeFlutter
LanguageJavaScript/TypeScriptDart
UINative componentsCustom canvas (Skia)
PerformanceBridge (JSI mới)Native (compiled)
EcosystemLớn, nhiều thư việnĐang phát triển
Hot reload
Bundle size~10MB~15MB

Setup#

# Dùng Expo (khuyến nghị)
npx create-expo-app my-app --template blank-typescript
cd my-app
npx expo start

# Hoặc React Native CLI
npx @react-native-community/cli init MyApp
bash

Components Cơ Bản#

State Management (Zustand)#

Network Calls#

Native Features#

Performance#

Deploy#

# Android — APK/AAB
cd android
./gradlew assembleRelease
# File ở android/app/build/outputs/apk/release/

# iOS — Archive
# Mở .xcworkspace trong Xcode → Product → Archive

# EAS Build (Expo)
eas build --platform all --profile production
eas submit --platform ios
eas submit --platform android
bash

Expo vs React Native CLI#

ExpoReact Native CLI
✅ Dễ setup, không cần Xcode/Android StudioCần native environment
✅ OTA updatesPhải build lại
✅ 50+ prebuilt modulesTự config native
❌ Không dùng native module tùy chỉnh✅ Full native control
❌ Bundle size lớn hơn✅ Tối ưu hơn

Khuyến nghị: Bắt đầu với Expo. Chỉ chuyển sang bare workflow khi cần native module đặc biệt.

Kết Luận#

React Native là lựa chọn tốt cho mobile app nếu bạn đã biết React:

  • Một codebase cho iOS + Android
  • Hot reload
  • Ecosystem lớn (Expo, React Navigation, TanStack Query)
  • Có thể fallback sang native code khi cần

Bắt đầu với Expo + TypeScript, thêm navigation với React Navigation, state với Zustand + TanStack Query, deploy với EAS Build.

Tài liệu tham khảo#