You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Continuation of #14319 which was closed by a bot. I would hope that a maintainer takes the time and reopens the original issue and closes this one, thanks.
Do you want to request a feature or report a bug?
Expose an API to get the display name of every component (in __DEV__ only).
What is the current behavior?
Most of the ecosystem still uses Component.displayName || Component.name || someFallbackName
(with some branching depending on the type of Component) when setting the display name of an enhanced component i.e. connect()(WrappedComponent) will result in "connect(WrappedComponent)" as a displayName.
If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. Your bug will get fixed much faster if we can run your code and it doesn't have dependencies other than React. Paste the link to your JSFiddle (https://jsfiddle.net/Luktwrdm/) or CodeSandbox (https://codesandbox.io/s/new) example below:
Since components created by forwardRef or memo are not actual functions these higher-order components are not able to determine a proper display name while react-devtools is able to:
Grant access to the functionality used in react-devtools (or would this only work on the fibers?)
Set a name (or displayName no preference here) property on those "exotic-components" (don't know how to call them). Naive implementation e.g.: name: 'ForwardRef(' + fn.name + ')'.
Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?
I guess this started with forwardRef in 16.3.
The text was updated successfully, but these errors were encountered:
Continuation of #14319 which was closed by a bot. I would hope that a maintainer takes the time and reopens the original issue and closes this one, thanks.
TL;DR: Can you expose shared/getComponentName?
Do you want to request a feature or report a bug?
Expose an API to get the display name of every component (in
__DEV__
only).What is the current behavior?
Most of the ecosystem still uses
Component.displayName || Component.name || someFallbackName
(with some branching depending on the type of
Component
) when setting the display name of an enhanced component i.e.connect()(WrappedComponent)
will result in"connect(WrappedComponent)"
as adisplayName
.If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. Your bug will get fixed much faster if we can run your code and it doesn't have dependencies other than React. Paste the link to your JSFiddle (https://jsfiddle.net/Luktwrdm/) or CodeSandbox (https://codesandbox.io/s/new) example below:
Since components created by
forwardRef
ormemo
are not actual functions these higher-order components are not able to determine a proper display name whilereact-devtools
is able to:https://codesandbox.io/s/zqj9v50243
react-redux
creates"connect(Component)"
react-router
creates"withRouter(undefined)"
What is the expected behavior?
The new "exotic-components" should work with the existing 3rd party libraries WRT to
displayName
.Now there are a couple of solutions to this issue:
react-devtools
(or would this only work on the fibers?)name
(ordisplayName
no preference here) property on those "exotic-components" (don't know how to call them). Naive implementation e.g.:name: 'ForwardRef(' + fn.name + ')'
.Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?
I guess this started with
forwardRef
in 16.3.The text was updated successfully, but these errors were encountered: