Function withDisplayName

  • creates an empty component with a given display name for debugging the component tree

    Type Parameters

    • T extends ComponentType<any>

    Parameters

    • name: ((Component) => string)
        • (Component): string
        • Parameters

          • Component: T

          Returns string

    Returns ((component) => T)

      • (component): T
      • Parameters

        • component: T

        Returns T

    Example

    const Component = withDisplayName('SomeName')(Example);
    <Component {...props} />
    // is equivalent to
    <SomeName> // this is just a Fragment with displayName property as `SomeName`
    <Example {...props} />
    </SomeName>

    Example

    withDisplayName('SomeName')(Example);
    // or
    withDisplayName('SomeName', Example);
    // or
    withDisplayName((Component) => 'SomeName.' + componentDisplayName.get(Component))(Example);
    // or
    withHocs([withDisplayName('SomeName')])(Example);
  • creates an empty component with a given display name for debugging the component tree

    Type Parameters

    • T extends ComponentType<any>

    Parameters

    • name: ((Component) => string)
        • (Component): string
        • Parameters

          • Component: T

          Returns string

    • Component: T

    Returns T

    Example

    const Component = withDisplayName('SomeName')(Example);
    <Component {...props} />
    // is equivalent to
    <SomeName> // this is just a Fragment with displayName property as `SomeName`
    <Example {...props} />
    </SomeName>

    Example

    withDisplayName('SomeName')(Example);
    // or
    withDisplayName('SomeName', Example);
    // or
    withDisplayName((Component) => 'SomeName.' + componentDisplayName.get(Component))(Example);
    // or
    withHocs([withDisplayName('SomeName')])(Example);
  • creates an empty component with a given display name for debugging the component tree

    Parameters

    • name: string

    Returns (<T>(component) => T)

      • <T>(component): T
      • Type Parameters

        • T extends ComponentType<any>

        Parameters

        • component: T

        Returns T

    Example

    const Component = withDisplayName('SomeName')(Example);
    <Component {...props} />
    // is equivalent to
    <SomeName> // this is just a Fragment with displayName property as `SomeName`
    <Example {...props} />
    </SomeName>

    Example

    withDisplayName('SomeName')(Example);
    // or
    withDisplayName('SomeName', Example);
    // or
    withDisplayName((Component) => 'SomeName.' + componentDisplayName.get(Component))(Example);
    // or
    withHocs([withDisplayName('SomeName')])(Example);
  • creates an empty component with a given display name for debugging the component tree

    Type Parameters

    • T extends ComponentType<any>

    Parameters

    • name: string
    • component: T

    Returns T

    Example

    const Component = withDisplayName('SomeName')(Example);
    <Component {...props} />
    // is equivalent to
    <SomeName> // this is just a Fragment with displayName property as `SomeName`
    <Example {...props} />
    </SomeName>

    Example

    withDisplayName('SomeName')(Example);
    // or
    withDisplayName('SomeName', Example);
    // or
    withDisplayName((Component) => 'SomeName.' + componentDisplayName.get(Component))(Example);
    // or
    withHocs([withDisplayName('SomeName')])(Example);

Generated using TypeDoc