ရိုးရိုးလေး ရှင်းပြမယ်
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 အဖြစ်နားလည်ပါ။
- JavaScript state
- Native component + layout
- Android / iOS UI
Core Components (View, Text, Image, ScrollView) ရဲ့ React နဲ့ native platform behavior ကိုရှင်းပြနိုင်ရန်
အဓိက Syntax / Pattern
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 ကို အဆင့်လိုက်ဖတ်မယ်
- JavaScript state
import { 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 အရေအတွက် များတဲ့အခါ လိုအပ်ပါတယ်။
- 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 အဖြစ်နားလည်ပါ။
- 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 ကိုလိုအပ်သလိုအသုံးပြုပါ။
- JavaScript state
- Native component + layout
- 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 နမူနာ
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 },
});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 ကိုခန့်မှန်းပါ
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
Quick Quiz 2 / 3
Quick Quiz 3 / 3
ဒီသင်ခန်းစာမှာ မှတ်ထားရမယ့်အချက်များ
- 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