Function withOverrides

  • adds values to many props, they can not be override, which means the given values override others

    Type Parameters

    • Map extends Record<string, unknown>

    Parameters

    Returns Hoc<[WithOverridesFn<ToSchema<Map>>]>

    See

    withOverride withFactory withDefaults withDefault

    Example

    function Card({ content, icon, border }: {
    content: string;
    icon: "star" | "heart" | ...;
    border: "none" | "dashed" | ...
    }) {
    return <>...</>
    }
    const StandardCard = withOverrides({icon: "star", border: "rounded"})(Card);

    <StandardCard content="some content" />
    // is equivalent to
    <CardWithIcon content="some content" icon="star" border="rounded" />

    // and
    <StandardCard content="some content" icon="heart" border="dashed" /> // ❌ is a typescript error, but even though
    // is equivalent to
    <CardWithIcon content="some content" icon="star" border="rounded" />

Generated using TypeDoc