ခဏလေး ဒီလိုပဲ စဉ်းစားကြည့်
ဒီ practice set က tutorial ရဲ့ အစောပိုင်း chapter တွေမှာ သင်ခဲ့တဲ့ routing၊ layout၊ component boundary skill တွေကို အသစ်ဘာမှမသင်ဘဲ ကိုယ်တိုင်ပြန်လက်တွေ့လုပ်ကြည့်ဖို့ ရည်ရွယ်ပါတယ်။ Task တစ်ခုစီက ခဏတိုလေးအတွင်း ပြီးနိုင်တဲ့ scope သေးငယ်ပါတယ်။ Solution တစ်ခုတည်းရှိတာမဟုတ်ပါဘူး — အရေးကြီးတာက concept ကို ကိုယ်ပိုင် code နဲ့ ပြန်ရေးနိုင်ဖို့ပါ။
လေ့ကျင့်ခန်းများ
(1) app/about/page.tsx static route တစ်ခု ဖန်တီးပြီး root layout ထဲက nav မှာ Link ထည့်ပါ။ (2) app/products/[slug]/page.tsx dynamic route ဖန်တီးပြီး params.slug ကို heading အဖြစ်ပြပါ။ (3) app/(marketing)/ route group တစ်ခုဖန်တီးပြီး ၎င်းအောက်မှာ layout သီးခြားတစ်ခု (background color ကွဲတဲ့) ထည့်ပါ — URL path ပေါ်မှာ group folder အမည်မပါဘဲ ကျန်ရစ်ကြောင်း confirm လုပ်ပါ။ (4) button click count ပြထားတဲ့ Counter component တစ်ခုကို "use client" directive နဲ့ ဖန်တီးပြီး Server Component ဖြစ်တဲ့ page ထဲမှာ import လုပ်ကြည့်ပါ.
Code နမူနာ
// Task 4 starter skeleton — components/Counter.tsx
"use client";
import { useState } from "react";
export default function Counter() {
const [count, setCount] = useState(0);
return (
<button onClick={() => setCount(count + 1)}>
Clicked {count} times
</button>
);
}
// app/products/[slug]/page.tsx skeleton
export default function ProductPage({ params }: { params: { slug: string } }) {
return <h2>Product: {params.slug}</h2>;
}Task လေးခုစလုံးပြီးရင် app ထဲမှာ route အသစ် 3 ခုနဲ့ interactive client component တစ်ခု ပေါင်းစပ်အလုပ်လုပ်နေတာ တွေ့ရပါလိမ့်မယ်။၅ မိနစ် စမ်းကြည့်
Task (2) ရဲ့ dynamic route ကို /products/abc, /products/123 စတဲ့ slug မတူတဲ့ URL 2-3 ခုနဲ့ browser ထဲစမ်းကြည့်ပြီး heading ပြောင်းသွားတာကို 5 မိနစ်အတွင်း confirm လုပ်ပါ။
သတိလေးတစ်ချက်
task တစ်ခုစီကို ပြီးတိုင်း dev server error console ကို check ပါ — TypeScript type error တွေက build မှာမှမတွေ့ခင် terminal ထဲမှာ ချက်ချင်းပေါ်တတ်ပါတယ်။