React හි ළමා සංරචක නිර්මාණය කිරීම
සංරචක ටැග්වල ගුණාංගවලට නොගැලපෙන පේළි පමණක් නොව, විචල්යයන් සහ නියතයන් ඇතුළත් කිරීම ද සිදු කළ හැකිය:
function App() {
const name = 'product';
const cost = '100';
return <div>
<Product name={name} cost={cost} />
</div>;
}
අපි එකවර නිෂ්පාදිත කිහිපයක් සාදමු:
function App() {
const name1 = 'product1';
const cost1 = '100';
const name2 = 'product2';
const cost2 = '100';
const name3 = 'product3';
const cost3 = '100';
return <div>
<Product name={name1} cost={cost1} />
<Product name={name2} cost={cost2} />
<Product name={name3} cost={cost3} />
</div>;
}
ඔබගේ සංරචකවලින් එකක් මත ඉගෙන ගත් දේ පරීක්ෂා කර බලන්න.