Thanks to visit codestin.com
Credit goes to github.com

Skip to content

displayName in components should be static #2581

Closed
@rondonjon

Description

@rondonjon

The react/display-name documentation doesn't explicitly state it, but the rule seems to accept display names as properties inside components.

=> Documentation needs to be updated

When the displayName was defined as a property, I think the rule should ensure that the declaration is static, so the following case should be rejected:

class Demo extends Component {
  displayName = "Demo"
}

Whereas the following should be accepted:

class Demo extends Component {
  static displayName = "Demo"
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions