ရိုးရိုးလေး ရှင်းပြမယ်
Mini Project Part 1: Todo App — Setup & UI ကို ရိုးရိုးလေးနားလည်မယ်
Todo App ရဲ့ UI structure က: header (title), input row (TextInput + Add button), todo list (FlatList), todo item (checkbox + text + delete button) ဆိုပြီး component ၄ ပိုင်း ခွဲထားပါတယ် — component တစ်ခုစီရဲ့ responsibility ကို ရှင်းလင်းစွာ ခွဲထားရင် Part 2 (state logic) ကို ထည့်တဲ့အခါ ပိုလွယ်ကူပါတယ်။
Problem → Why → Solution
ပြဿနာ — ဘာကြောင့် ဒီ concept လိုတာလဲ
Component တစ်ခုတည်းထဲ everything ကို ရေးပြီး Part 2 မှာ state ချိတ်တဲ့အခါ ရှုပ်ထွေးခြင်း — logical section ခွဲထားခြင်းက အရေးကြီး
ဖြစ်လေ့ရှိတဲ့အမှား
flexDirection: 'row' ကို input row ကနေ ချန်ထားခဲ့ပြီး TextInput/button ဘေးချင်းကပ်မနေခြင်း
Core Concept — အလုပ်လုပ်ပုံကိုနားလည်မယ်
Mini Project Part 1: Todo App — Setup & UI ကို Debug build တစ်ခုတည်းဖြင့်မဆုံးဖြတ်ဘဲ release device ပေါ်တွင် startup, JS/UI frame rate, memory, network, crash recovery, permissions, signing နဲ့ store requirements ဖြင့်စစ်ပါ။ New Architecture compatibility နဲ့ dependency support ကို upgrade တိုင်းအတည်ပြုပါ။
- Project requirements
- Components + state + services
- စမ်းသပ်ပြီး UI
Mini Project Part 1: Todo App — Setup & UI ရဲ့ React နဲ့ native platform behavior ကိုရှင်းပြနိုင်ရန်
အဓိက Syntax / Pattern
import { View, Text, TextInput, TouchableOpacity, FlatList, StyleSheet } from 'react-native';
const placeholderTodos = [
{ id: '1', text: 'React Native လေ့လာမယ်', done: false },
{ id: '2', text: 'Todo app ဆောက်မယ်', done: true },
];
export default function TodoApp() {
return (
<View style={styles.container}>
<Text style={styles.header}>My Todo App</Text>
<View style={styles.inputRow}>
<TextInput style={styles.input} placeholder="Add a todo..." />
<TouchableOpacity style={styles.addButton}>
<Text style={styles.addButtonText}>Add</Text>
</TouchableOpacity>
</View>
<FlatList
data={placeholderTodos}
keyExtractor={(item) => item.id}
renderItem={({ item }) => (
<View style={styles.todoItem}>
<Text>{item.done ? '☑️' : '☐'} {item.text}</Text>
</View>
)}
/>
</View>
);
}
const styles = StyleSheet.create({
container: { flex: 1, padding: 16 },
header: { fontSize: 24, fontWeight: 'bold', marginBottom: 16 },
inputRow: { flexDirection: 'row', marginBottom: 16 },
input: { flex: 1, borderWidth: 1, borderColor: '#ccc', borderRadius: 8, padding: 10, marginRight: 8 },
addButton: { backgroundColor: '#3b82f6', padding: 10, borderRadius: 8, justifyContent: 'center' },
addButtonText: { color: 'white', fontWeight: '600' },
todoItem: { padding: 12, borderBottomWidth: 1, borderColor: '#eee' },
});Mini Project Part 1: Todo App — Setup & UI ကို Debug build တစ်ခုတည်းဖြင့်မဆုံးဖြတ်ဘဲ release device ပေါ်တွင် startup, JS/UI frame rate, memory, network, crash recovery, permissions, signing နဲ့ store requirements ဖြင့်စစ်ပါ။ New Architecture compatibility နဲ့ dependency support ကို upgrade တိုင်းအတည်ပြုပါ။
Code ကို အဆင့်လိုက်ဖတ်မယ်
- Project requirements
import { View, Text, TextInput, TouchableOpacity, Fla...Todo App ရဲ့ UI structure က: header (title), input row (TextInput + Add button), todo list (FlatList), todo item (checkbox + text + delete button) ဆိုပြီး component ၄ ပိုင်း ခွဲထားပါတယ် — component တစ်ခုစီရဲ့ responsibility ကို ရှင်းလင်းစွာ ခွဲထားရင် Part 2 (state logic) ကို ထည့်တဲ့အခါ ပိုလွယ်ကူပါတယ်။
- Components + state + services
renderItem={({ item }) => (Mini Project Part 1: Todo App — Setup & UI ကို Debug build တစ်ခုတည်းဖြင့်မဆုံးဖြတ်ဘဲ release device ပေါ်တွင် startup, JS/UI frame rate, memory, network, crash recovery, permissions, signing နဲ့ store requirements ဖြင့်စစ်ပါ။ New Architecture compatibility နဲ့ dependency support ကို upgrade တိုင်းအတည်ပြုပါ။
- စမ်းသပ်ပြီး UI
});Mini Project Part 1: Todo App — Setup & UI 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 ကိုလိုအပ်သလိုအသုံးပြုပါ။
- Project requirements
- Components + state + services
- စမ်းသပ်ပြီး UI
Success
Mini Project Part 1: Todo App — Setup & UI ရဲ့ React နဲ့ native platform behavior ကိုရှင်းပြနိုင်ရန်
Failure
Component တစ်ခုတည်းထဲ everything ကို ရေးပြီး Part 2 မှာ state ချိတ်တဲ့အခါ ရှုပ်ထွေးခြင်း — logical section ခွဲထားခြင်းက အရေးကြီး
ခဏလေး ဒီလိုပဲ စဉ်းစားကြည့်
Todo App ရဲ့ UI structure က: header (title), input row (TextInput + Add button), todo list (FlatList), todo item (checkbox + text + delete button) ဆိုပြီး component ၄ ပိုင်း ခွဲထားပါတယ် — component တစ်ခုစီရဲ့ responsibility ကို ရှင်းလင်းစွာ ခွဲထားရင် Part 2 (state logic) ကို ထည့်တဲ့အခါ ပိုလွယ်ကူပါတယ်။
လက်တွေ့ scenario နဲ့ ချိတ်ကြည့်မယ်
Header, input row, todo list section ၃ ခုကို View ဖြင့် ခွဲထားပြီး flexbox (flexDirection: row for input row) ကို သုံးပါ — ဒီအဆင့်မှာ state ကို static array (placeholder data) နဲ့ hardcode ထားရုံပါ, Part 2 မှာ useState ချိတ်ဆက်ပါမယ်။ TouchableOpacity ကို 'Add' button, checkbox icon (☐/☑️), delete icon (🗑️) အတွက် သုံးပါ။
Code နမူနာ
import { View, Text, TextInput, TouchableOpacity, FlatList, StyleSheet } from 'react-native';
const placeholderTodos = [
{ id: '1', text: 'React Native လေ့လာမယ်', done: false },
{ id: '2', text: 'Todo app ဆောက်မယ်', done: true },
];
export default function TodoApp() {
return (
<View style={styles.container}>
<Text style={styles.header}>My Todo App</Text>
<View style={styles.inputRow}>
<TextInput style={styles.input} placeholder="Add a todo..." />
<TouchableOpacity style={styles.addButton}>
<Text style={styles.addButtonText}>Add</Text>
</TouchableOpacity>
</View>
<FlatList
data={placeholderTodos}
keyExtractor={(item) => item.id}
renderItem={({ item }) => (
<View style={styles.todoItem}>
<Text>{item.done ? '☑️' : '☐'} {item.text}</Text>
</View>
)}
/>
</View>
);
}
const styles = StyleSheet.create({
container: { flex: 1, padding: 16 },
header: { fontSize: 24, fontWeight: 'bold', marginBottom: 16 },
inputRow: { flexDirection: 'row', marginBottom: 16 },
input: { flex: 1, borderWidth: 1, borderColor: '#ccc', borderRadius: 8, padding: 10, marginRight: 8 },
addButton: { backgroundColor: '#3b82f6', padding: 10, borderRadius: 8, justifyContent: 'center' },
addButtonText: { color: 'white', fontWeight: '600' },
todoItem: { padding: 12, borderBottomWidth: 1, borderColor: '#eee' },
});Header, input row, placeholder todo list ၂ ခု ပါတဲ့ static UI screen တစ်ခု ပြီးစီးမည်။၅ မိနစ် စမ်းကြည့်
ဒီ UI structure ကို ကိုယ်တိုင် ရိုက်ထည့်ပြီး Expo Go ပေါ်မှာ run ကြည့်ပါ — placeholder data ၂ ခုကို ကိုယ်ပိုင် todo item စာသားနဲ့ ပြောင်းကြည့်ပါ။
သတိလေးတစ်ချက်
ဒီအဆင့်မှာ Add button/checkbox ကို press ကြည့်လည်း ဘာမှ မဖြစ်သေးပါဘူး (event handler မထည့်ရသေး) — Part 2 မှာ state logic ထည့်မှ interactive ဖြစ်လာမှာပါ။
Real-world usage
လက်တွေ့ Project မှာ ဘယ်လိုသုံးမလဲ
Mini Project Part 1: Todo App — Setup & UI 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
ကိုယ်တိုင်တည်ဆောက်ကြည့်ပါ
Mini Project Part 1: Todo App — Setup & UI 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, TextInput, TouchableOpacity, FlatList, StyleSheet } from 'react-native';
const placeholderTodos = [
{ id: '1', text: 'React Native လေ့လာမယ်', done: false },
{ id: '2', text: 'Todo app ဆောက်မယ်', done: true },
];
export default function TodoApp() {
return (
<View style={styles.container}>
<Text style={styles.header}>My Todo App</Text>
<View style={styles.inputRow}>
<TextInput style={styles.input} placeholder="Add a todo..." />
<TouchableOpacity style={styles.addButton}>
<Text style={styles.addButtonText}>Add</Text>
</TouchableOpacity>
</View>
<FlatList
data={placeholderTodos}
keyExtractor={(item) => item.id}
renderItem={({ item }) => (
<View style={styles.todoItem}>
<Text>{item.done ? '☑️' : '☐'} {item.text}</Text>
</View>
)}
/>
</View>
);
}
const styles = StyleSheet.create({
container: { flex: 1, padding: 16 },
header: { fontSize: 24, fontWeight: 'bold', marginBottom: 16 },
inputRow: { flexDirection: 'row', marginBottom: 16 },
input: { flex: 1, borderWidth: 1, borderColor: '#ccc', borderRadius: 8, padding: 10, marginRight: 8 },
addButton: { backgroundColor: '#3b82f6', padding: 10, borderRadius: 8, justifyContent: 'center' },
addButtonText: { color: 'white', fontWeight: '600' },
todoItem: { padding: 12, borderBottomWidth: 1, borderColor: '#eee' },
});ရလဒ်: Mini Project Part 1: Todo App — Setup & UI ရဲ့ React နဲ့ native platform behavior ကိုရှင်းပြနိုင်ရန်
အရိပ်အမြွက် ကြည့်ရန်
Mini Project Part 1: Todo App — Setup & UI 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
ဒီသင်ခန်းစာမှာ မှတ်ထားရမယ့်အချက်များ
- Project requirements → Components + state + services → စမ်းသပ်ပြီး UI
- Mini Project Part 1: Todo App — Setup & UI ကို Debug build တစ်ခုတည်းဖြင့်မဆုံးဖြတ်ဘဲ release device ပေါ်တွင် startup, JS/UI frame rate, memory, network, crash recovery, permissions, signing နဲ့ store requirements ဖြင့်စစ်ပါ။ New Architecture compatibility နဲ့ dependency support ကို upgrade တိုင်းအတည်ပြုပါ။
- Component တစ်ခုတည်းထဲ everything ကို ရေးပြီး Part 2 မှာ state ချိတ်တဲ့အခါ ရှုပ်ထွေးခြင်း — logical section ခွဲထားခြင်းက အရေးကြီး
- Mini Project Part 1: Todo App — Setup & UI 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