Thuta Learning
React Native
BasicMobile Developmentအလယ်အလတ်

Core Components (View, Text, Image, ScrollView)

React Nativeသင်ခန်းစာ 420 မိနစ်

ဒီခန်းပြီးရင် ဘာတတ်သွားမလဲ

  • Core Components (View, Text, Image, ScrollView) ရဲ့ React နဲ့ native platform behavior ကိုရှင်းပြနိုင်ရန်
  • Accessibility, failure နဲ့ lifecycle cases စမ်းနိုင်ရန်
  • Maintainable, testable နဲ့ performant React Native code ရေးနိုင်ရန်

ရိုးရိုးလေး ရှင်းပြမယ်

Core Components (View, Text, Image, ScrollView) ကို ရိုးရိုးလေးနားလည်မယ်

View က layout container ပါ (HTML ရဲ့ <div> နဲ့ တူ) — child component တွေကို group/arrange လုပ်ဖို့ သုံးပါတယ်။ Text က text content ပြသဖို့ တစ်ခုတည်းသော component ပါ (font size/color စတဲ့ text styling ကို Text ထဲမှာပဲ လုပ်ရပါတယ်)။ Image က ပုံပြဖို့သုံးပြီး local file (require) ဒါမှမဟုတ် remote URL (uri) နှစ်မျိုးလက်ခံပါတယ်။ ScrollView က content ကို screen height ထက်ကျော်ရင် scroll လုပ်နိုင်စေတဲ့ container ပါ — content အရေအတွက် များတဲ့အခါ လိုအပ်ပါတယ်။

Problem → Why → Solution

ပြဿနာ — ဘာကြောင့် ဒီ concept လိုတာလဲ

Image source ကို local file (require) နဲ့ remote URL (uri object) syntax ရောသုံးမိခြင်း

ဖြစ်လေ့ရှိတဲ့အမှား

ScrollView ကို content တိုတိုအတွက်ပါ default အသုံးပြုပြီး unnecessary nesting ဖြစ်ခြင်း

Core Concept — အလုပ်လုပ်ပုံကိုနားလည်မယ်

Core Components (View, Text, Image, ScrollView) ကို screen တစ်ခုအတွက် style syntax အဖြစ်သာမမြင်ဘဲ Yoga constraints, pixel density, font scaling, safe areas, keyboard, touch target, accessibility tree နဲ့ iOS/Android behavior ကွာခြားမှုတို့ပါသော native UI contract အဖြစ်နားလည်ပါ။

Mental Model
  1. JavaScript state
  2. Native component + layout
  3. Android / iOS UI

Core Components (View, Text, Image, ScrollView) ရဲ့ React နဲ့ native platform behavior ကိုရှင်းပြနိုင်ရန်

အဓိက Syntax / Pattern

javascript
import { View, Text, Image, ScrollView, StyleSheet } from 'react-native';

export default function ProfileScreen() {
  return (
    <ScrollView style={styles.container}>
      <Image
        source={{ uri: 'https://example.com/avatar.png' }}
        style={styles.avatar}
      />
      <Text style={styles.name}>Mya Mya</Text>
      <Text>Software developer, learning React Native.</Text>
    </ScrollView>
  );
}

const styles = StyleSheet.create({
  container: { flex: 1, padding: 16 },
  avatar: { width: 100, height: 100, borderRadius: 50 },
  name: { fontSize: 20, fontWeight: 'bold', marginTop: 8 },
});

Core Components (View, Text, Image, ScrollView) ကို screen တစ်ခုအတွက် style syntax အဖြစ်သာမမြင်ဘဲ Yoga constraints, pixel density, font scaling, safe areas, keyboard, touch target, accessibility tree နဲ့ iOS/Android behavior ကွာခြားမှုတို့ပါသော native UI contract အဖြစ်နားလည်ပါ။

Code ကို အဆင့်လိုက်ဖတ်မယ်

  1. JavaScript stateimport { View, Text, Image, ScrollView, StyleSheet } ...

    View က layout container ပါ (HTML ရဲ့ <div> နဲ့ တူ) — child component တွေကို group/arrange လုပ်ဖို့ သုံးပါတယ်။ Text က text content ပြသဖို့ တစ်ခုတည်းသော component ပါ (font size/color စတဲ့ text styling ကို Text ထဲမှာပဲ လုပ်ရပါတယ်)။ Image က ပုံပြဖို့သုံးပြီး local file (require) ဒါမှမဟုတ် remote URL (uri) နှစ်မျိုးလက်ခံပါတယ်။ ScrollView က content ကို screen height ထက်ကျော်ရင် scroll လုပ်နိုင်စေတဲ့ container ပါ — content အရေအတွက် များတဲ့အခါ လိုအပ်ပါတယ်။

  2. Native component + layout<Text>Software developer, learning React Native.</Text>

    Core Components (View, Text, Image, ScrollView) ကို screen တစ်ခုအတွက် style syntax အဖြစ်သာမမြင်ဘဲ Yoga constraints, pixel density, font scaling, safe areas, keyboard, touch target, accessibility tree နဲ့ iOS/Android behavior ကွာခြားမှုတို့ပါသော native UI contract အဖြစ်နားလည်ပါ။

  3. Android / iOS UI});

    Core Components (View, Text, Image, ScrollView) example ကို Android/iOS, small/large screens, font scaling, dark mode, keyboard, screen reader, slow/offline network, denied permissions နဲ့ app background/foreground cases ဖြင့်စမ်းပါ။ DevTools, tests နဲ့ release build ကိုလိုအပ်သလိုအသုံးပြုပါ။

Execution Flow
  1. JavaScript state
  2. Native component + layout
  3. Android / iOS UI

Success

Core Components (View, Text, Image, ScrollView) ရဲ့ React နဲ့ native platform behavior ကိုရှင်းပြနိုင်ရန်

Failure

Image source ကို local file (require) နဲ့ remote URL (uri object) syntax ရောသုံးမိခြင်း

ခဏလေး ဒီလိုပဲ စဉ်းစားကြည့်

View က layout container ပါ (HTML ရဲ့ <div> နဲ့ တူ) — child component တွေကို group/arrange လုပ်ဖို့ သုံးပါတယ်။ Text က text content ပြသဖို့ တစ်ခုတည်းသော component ပါ (font size/color စတဲ့ text styling ကို Text ထဲမှာပဲ လုပ်ရပါတယ်)။ Image က ပုံပြဖို့သုံးပြီး local file (require) ဒါမှမဟုတ် remote URL (uri) နှစ်မျိုးလက်ခံပါတယ်။ ScrollView က content ကို screen height ထက်ကျော်ရင် scroll လုပ်နိုင်စေတဲ့ container ပါ — content အရေအတွက် များတဲ့အခါ လိုအပ်ပါတယ်။

လက်တွေ့ scenario နဲ့ ချိတ်ကြည့်မယ်

Profile screen တစ်ခု ဆောက်မယ်ဆိုရင် outer View ထဲမှာ Image (profile photo), Text (name, bio), ကျန် content တွေကို ScrollView ထဲမှာ ထားလေ့ရှိပါတယ် — screen size (phone အမျိုးမျိုး) မတူတဲ့အတွက် content ရှည်ရင် ScrollView မပါရင် အောက်ခြေကျန်တဲ့ content ကို မမြင်ရနိုင်ပါဘူး။

Code နမူနာ

javascript
import { View, Text, Image, ScrollView, StyleSheet } from 'react-native';

export default function ProfileScreen() {
  return (
    <ScrollView style={styles.container}>
      <Image
        source={{ uri: 'https://example.com/avatar.png' }}
        style={styles.avatar}
      />
      <Text style={styles.name}>Mya Mya</Text>
      <Text>Software developer, learning React Native.</Text>
    </ScrollView>
  );
}

const styles = StyleSheet.create({
  container: { flex: 1, padding: 16 },
  avatar: { width: 100, height: 100, borderRadius: 50 },
  name: { fontSize: 20, fontWeight: 'bold', marginTop: 8 },
});
You should see
Profile screen ပေါ်မှာ avatar image, name, bio ကို scroll လုပ်ကြည့်နိုင်အောင် layout ချနိုင်မည်။

၅ မိနစ် စမ်းကြည့်

View, Text, Image, ScrollView ကို ပေါင်းသုံးပြီး ကိုယ်ပိုင် simple profile screen တစ်ခု တည်ဆောက်ကြည့်ပါ။

သတိလေးတစ်ချက်

Image ရဲ့ style ထဲမှာ width/height ကို သတ်မှတ်မထားရင် ပုံလုံးဝ မပေါ်နိုင်ပါဘူး (default size မရှိလို့) — local file ဆိုရင် auto-size ရနိုင်ပေမယ့် remote URI ကတော့ အမြဲ width/height လိုအပ်ပါတယ်။

Real-world usage

လက်တွေ့ Project မှာ ဘယ်လိုသုံးမလဲ

Core Components (View, Text, Image, ScrollView) example ကို Android/iOS, small/large screens, font scaling, dark mode, keyboard, screen reader, slow/offline network, denied permissions နဲ့ app background/foreground cases ဖြင့်စမ်းပါ။ DevTools, tests နဲ့ release build ကိုလိုအပ်သလိုအသုံးပြုပါ။

Mini challenge

ကိုယ်တိုင်တည်ဆောက်ကြည့်ပါ

Core Components (View, Text, Image, ScrollView) example ကို Android/iOS, small/large screens, font scaling, dark mode, keyboard, screen reader, slow/offline network, denied permissions နဲ့ app background/foreground cases ဖြင့်စမ်းပါ။ DevTools, tests နဲ့ release build ကိုလိုအပ်သလိုအသုံးပြုပါ။

  • Example ကို copy မလုပ်ဘဲ ပြန်ရေးပါ
  • Normal input နဲ့ edge case စမ်းပါ
  • Run မလုပ်မီ compiler/output result ကိုခန့်မှန်းပါ
javascript
import { View, Text, Image, ScrollView, StyleSheet } from 'react-native';

export default function ProfileScreen() {
  return (
    <ScrollView style={styles.container}>
      <Image
        source={{ uri: 'https://example.com/avatar.png' }}
        style={styles.avatar}
      />
      <Text style={styles.name}>Mya Mya</Text>
      <Text>Software developer, learning React Native.</Text>
    </ScrollView>
  );
}

const styles = StyleSheet.create({
  container: { flex: 1, padding: 16 },
  avatar: { width: 100, height: 100, borderRadius: 50 },
  name: { fontSize: 20, fontWeight: 'bold', marginTop: 8 },
});

ရလဒ်: Core Components (View, Text, Image, ScrollView) ရဲ့ React နဲ့ native platform behavior ကိုရှင်းပြနိုင်ရန်

အရိပ်အမြွက် ကြည့်ရန်

Core Components (View, Text, Image, ScrollView) example ကို Android/iOS, small/large screens, font scaling, dark mode, keyboard, screen reader, slow/offline network, denied permissions နဲ့ app background/foreground cases ဖြင့်စမ်းပါ။ DevTools, tests နဲ့ release build ကိုလိုအပ်သလိုအသုံးပြုပါ။

Quick Quiz 1 / 3

Core Components (View, Text, Image, ScrollView) ရဲ့ အဓိကသဘောတရားက ဘာလဲ။

Quick Quiz 2 / 3

ဘယ်အမှားကို အရင်ဆုံးရှောင်သင့်လဲ။

Quick Quiz 3 / 3

Real project မှာ ဘယ်လိုအသုံးချသင့်လဲ။

ဒီသင်ခန်းစာမှာ မှတ်ထားရမယ့်အချက်များ

  • JavaScript state → Native component + layout → Android / iOS UI
  • Core Components (View, Text, Image, ScrollView) ကို screen တစ်ခုအတွက် style syntax အဖြစ်သာမမြင်ဘဲ Yoga constraints, pixel density, font scaling, safe areas, keyboard, touch target, accessibility tree နဲ့ iOS/Android behavior ကွာခြားမှုတို့ပါသော native UI contract အဖြစ်နားလည်ပါ။
  • Image source ကို local file (require) နဲ့ remote URL (uri object) syntax ရောသုံးမိခြင်း
  • Core Components (View, Text, Image, ScrollView) example ကို Android/iOS, small/large screens, font scaling, dark mode, keyboard, screen reader, slow/offline network, denied permissions နဲ့ app background/foreground cases ဖြင့်စမ်းပါ။ DevTools, tests နဲ့ release build ကိုလိုအပ်သလိုအသုံးပြုပါ။

React Native Documentation — React Native

ဒီနေရာမှာ လူအများမှားတတ်တယ်

  • Image source ကို local file (require) နဲ့ remote URL (uri object) syntax ရောသုံးမိခြင်း
  • ScrollView ကို content တိုတိုအတွက်ပါ default အသုံးပြုပြီး unnecessary nesting ဖြစ်ခြင်း
  • Simulator တစ်ခု၏ happy path မှန်ရုံဖြင့် real devices, release builds, permissions, accessibility, offline နဲ့ lifecycle paths အားလုံးမှန်ပြီဟုယူဆခြင်း။

လက်တွေ့လေ့ကျင့်ခန်း

Core Components (View, Text, Image, ScrollView) example ကို Android/iOS, small/large screens, font scaling, dark mode, keyboard, screen reader, slow/offline network, denied permissions နဲ့ app background/foreground cases ဖြင့်စမ်းပါ။ DevTools, tests နဲ့ release build ကိုလိုအပ်သလိုအသုံးပြုပါ။

အလုပ်ဖြစ်ကြောင်း ဒီလိုသိမယ်: Profile screen ပေါ်မှာ avatar image, name, bio ကို scroll လုပ်ကြည့်နိုင်အောင် layout ချနိုင်မည်။

နောက်ဆုံးပြင်ဆင်ရက်

Progress ကို ဤ browser (ဤစက်) တွင်သာ သိမ်းထားပါသည်။ အခြားစက်များနှင့် sync မလုပ်ပါ။

ဤသင်ခန်းစာတွင် အမှားတွေ့ပါက အကြောင်းကြားရန်သင့် email app ကို ဤသင်ခန်းစာလိပ်စာ ဖြည့်ပြီးသားဖြင့် ဖွင့်ပေးပါမည် — သင်ကိုယ်တိုင် ပို့မှသာ ပို့မည်ဖြစ်သည်။

Core Components (View, Text, Image, ScrollView) | Thuta Learning