react-compinators
    Preparing search index...

    Function withDefault

    • Convert a component that takes a required prop prop into a component where the prop is optional by providing a default value. The opposite of requireProp. When the returned component receives the prop, it will use it, but when none is given it will use the default given here.

      Type Parameters

      • Prop extends string

        Type of prop name. Must exist as a required field on Base props.

      • Value

        Prop type.

      Parameters

      • prop: Prop

        Name of required prop to convert.

      • value: Value

        Default value for prop.

      Returns <BaseProps extends Record<Prop, Value>>(
          Base: FC<BaseProps>,
      ) => FC<Simplify<WithDefaultProp<Prop, Value, BaseProps>>>