React တွင် ကုလားအိုး Components များ ဖန်တီးခြင်း
Component ၏ tag attributes များအတွင်းသို့ string များသာမက variable များနှင့် constant များကို ထည့်သွင်းခြင်းလည်း ပြုလုပ်နိုင်ပါသည်။
function App() {
const name = 'ထုတ်ကုန်';
const cost = '100';
return <div>
<Product name={name} cost={cost} />
</div>;
}
ထုတ်ကုန်များစွာကို တစ်ချိန်တည်း လုပ်ဆောင်ကြည့်ရအောင်။
function App() {
const name1 = 'ထုတ်ကုန် ၁';
const cost1 = '100';
const name2 = 'ထုတ်ကုန် ၂';
const cost2 = '100';
const name3 = 'ထုတ်ကုန် ၃';
const cost3 = '100';
return <div>
<Product name={name1} cost={cost1} />
<Product name={name2} cost={cost2} />
<Product name={name3} cost={cost3} />
</div>;
}
သင်လေ့လာထားသည်များကို သင့်ကိုယ်ပိုင် components တစ်ခုခုတွင် စမ်းသပ်အသုံးပြုကြည့်ပါ။