Typing props & children
Në shqip: Tipet e props dhe children
ShpjegimiSQ
Props-et e një komponenti i përshkruan me type ose interface. children ka tip React.ReactNode. React.FC përdorej shumë më parë, por sot rekomandohet të shkruash thjesht funksionin me props të tipizuara.
EnglishEN
A component's props are described with a type or interface. children has the type React.ReactNode. React.FC used to be common, but today it's recommended to write a plain function with typed props.
Si ta mendosh
Si lista e përbërësve në kutinë e një produkti.
Lexoje në anglisht
Like the ingredients list on a product's box.
Shembull koditypescript
type KartaProps = { titulli: string; children: React.ReactNode };
function Karta({ titulli, children }: KartaProps) {
return <section><h2>{titulli}</h2>{children}</section>;
}