Skip to content

displayName not working in React 17 with observer #2721

@codeBelt

Description

@codeBelt

Intended outcome:

In this old issue (#141) it states the below should work. Also In the docs it states it will be fixed in React 17.

export const MyComponent2 = observer(() => "hello2!");
MyComponent2.displayName = "MyComponent2";

Is this an issue with observer now and/or should the docs be updated to say displayName does not work with observer?

Actual outcome:
Viewing "React DevTools" in CodeSandbox notice _c3 for the MyComponent2 name:

Screen Shot 2021-01-18 at 8 37 06 AM

How to reproduce the issue:
https://codesandbox.io/s/mobx-displayname-reat-17-z61pb?file=/src/MyComponent.jsx

Versions

  • mobx: 6.0.4
  • mobx-react: 7.0.5
  • react: 17.0.1
  • react-dom: 17.0.1

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions