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
{{ message }}
Repository navigation
Support setting Context displayName in @babel/plugin-transform-react-display-name #11241
I have bandwidth to work on this feature in the near future. 🙁
Is your feature request related to a problem? Please describe.
Here's an example of React DevTools with a few context providers and consumers:
You'll notice that the context consumer and provider rendered under ThemeProvider have generic Context.Consumer and Context.Provider display names, but there's also a Router.Provider and Router.Consumer in there which are much more clear.
They accomplish this by setting the context's displayName value.
I can set it manually. Not desirable. Or I could write my own babel plugin, but then others wouldn't benefit from it if they either don't know about the plugin or can't install it. Also, this seems to make a lot of sense to be included here to me.
However, I think @babel/plugin-transform-react-display-name only supports assigning displayName to components created by createClass? I'm not sure if it should be the right target package we should build this into? Maybe I'm missing something 🤔
Yes, I believe that's true. That said, there's nothing in the name to suggest that all it handles and considering it's already used by projects which would want this feature I think it's an acceptable place to put this.
Activity
kevin940726 commentedon Mar 11, 2020
I would love to help :) !
However, I think
@babel/plugin-transform-react-display-nameonly supports assigningdisplayNameto components created bycreateClass? I'm not sure if it should be the right target package we should build this into? Maybe I'm missing something 🤔kentcdodds commentedon Mar 11, 2020
Yes, I believe that's true. That said, there's nothing in the name to suggest that all it handles and considering it's already used by projects which would want this feature I think it's an acceptable place to put this.
kevin940726 commentedon Mar 11, 2020
@kentcdodds Fair enough 👍! I'm just curious then why
babel-plugin-add-react-displaynameisn't also part of this?kentcdodds commentedon Mar 11, 2020
I'm also curious about that. I definitely prefer the trade-off of a few extra bytes to have a better production debugging experience.
nicolo-ribaudo commentedon Mar 11, 2020
Oh wow, I had no idea that our plugin was so outdated.
@roncohen Would you be open to adding this feature to
babel-plugin-add-react-displayname, and then mergingbabel-plugin-add-react-displaynameto the official Babel plugin?existentialism commentedon Mar 11, 2020
Related: #8748
ahutchings commentedon Nov 14, 2020
Related: #5679