react-compinators
    Preparing search index...

    Function unfoldProp

    • Unfold the given component into a component per member of the given union, where the given prop of each component is partially applied to a different member of the union.

      This code:

      const [GreenLabel, YellowLabel, RedLabel] = [
      assumeProp(BaseLabel, 'color')('green'),
      assumeProp(BaseLabel, 'color')('yellow'),
      assumeProp(BaseLabel, 'color')('red'),
      ]

      Can be rewritten using unfoldProp as:

      import {String} from 'effect'
      import {unfoldProp} from 'react-compinators'

      const [ GreenLabel, YellowLabel, RedLabel ] = unfoldProp(
      BaseLabel, // Base component.
      'color', // Prop that we will be setting.
      )(
      ['green', 'yellow', 'red'], // Array of union members.
      String.capitalize, // Optional function will be used to compute
      // variant displayName from its `color` prop.
      )

      Type Parameters

      • Props extends object
      • Prop extends string

      Parameters

      Returns <const Union extends readonly Props[Prop][]>(
          members: Union,
          buildDisplayName?: (value: Props[Prop]) => string,
      ) => TupleOf<Union["length"], FC<Simplify<Omit<Props, Prop>>>>