Skip to content

react/display-name regression #3121

Closed
Closed
@adriangodong

Description

@adriangodong

I have the following code that was working with eslint@7.32.0 and eslint-plugin-react@7.26.1:

export function wrapComponent<T>(WrappedComponent: React.ComponentType<T>): React.ComponentClass<T>
{
    return class extends React.Component<T>
    {
        displayName = `wrapped(${WrappedComponent.displayName})`;

        render()
        {
            ...
        }
    }
    return Container;
}

After upgrading to eslint@8.1.0, there's a linting error for react/display-name rule.

If I extract the class into an actual class and then return it, the linting error goes away, e.g.:

export function wrapComponent()...
{
    class Wrap extends React.Component<T>
    {
        displayName = `wrapped(${WrappedComponent.displayName})`;
        ...
    }
    return Wrap;
}

Activity

ljharb

ljharb commented on Nov 4, 2021

@ljharb
Member

We don't support eslint 8 yet; see #3055.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @ljharb@adriangodong

        Issue actions

          react/display-name regression · Issue #3121 · jsx-eslint/eslint-plugin-react