Skip to content

Component name as prop #15214

Closed
Closed
@sbussard

Description

@sbussard

Feature Request

Component name as props

Current behavior

You have to set .displayName in a second statement

const MyComponent = (props) => <Stuff />;

MyComponent.displayName = 'HeyHey'

https://stackoverflow.com/questions/43356073/how-to-set-displayname-in-a-functional-component-react

Desired behavior

You can set a component's displayName by setting a displayName prop, ideally anywhere in the component hierarchy, like so:

export default props => <Stuff displayName="MyStuff" />;

or so:

export default props => (
  <Fragment displayName="FragmentWithName">
    <Stuff displayName="HeyHey" />
  </Fragment>
);

Why

To make writing components less verbose

Other ideas:
facebook/react-devtools#1294

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

    Issue actions