Function withOverride

  • adds a prop value to the component, the given value can not be override, which means the given value overrides others

    Type Parameters

    • PropValue

    • PropName extends string

    Parameters

    Returns Hoc<[IfThenFn<HasAllPropsFn<PropName>, [...(PropValue extends ((...args) => any)
        ? []
        : [IntersectionFn<[PropName, PropValue]>])[], KeepNeversFn<OmitFn<PropName>>]>]>

    See

    withOverrides withFactory withDefault withDefaults

    Example

    function CardWithIcon({ content, icon }: {
    content: string;
    icon: "star" | "heart" | ...;
    }) {
    return <>...</>
    }
    const StandardCard = withOverride("icon", "star")(CardWithIcon);

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

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

Generated using TypeDoc