withDefault withFactory withOverrides withOverride
function Card({ content, icon, border }: {
content: string;
icon: "star" | "heart" | ...;
border: "none" | "dashed" | ...
}) {
return <>...</>
}
const StandardCard = withDefaults({icon: "star", border: "rounded"})(Card);
<StandardCard content="some content" />
// is equivalent to
<CardWithIcon icon="star" border="rounded" content="some content" />
// but
<StandardCard content="some content" icon="heart" border="dashed" />
// is equivalent to
<CardWithIcon content="some content" icon="heart" border="dashed" /> // it propagates the new value
Generated using TypeDoc
adds default values to many props, so they can still receive values but they now have a default