-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Observer HOC is not getting displayName from forwardRef #3422
Comments
Hm I don't think we can or should do something about this, because it's actually a problem of Regarding eslint-plugin, IIRC the plan was to remove/deprecate |
@urugator Thank you for the reply. and it looks like if we wrapping React.forwardRef, we can get its name from
|
Yea, I dunno what would be a proper thing to do here - whether we should get the name from ref wrapper as now or rather from wrapped component. Ideally it should behave as with react alone. The whole displayName business is a bit magical and can even differ from version to version. I would have to investigate, however I don't think it's worth it atm because once we apply memo, the displayName seems lost anyway. Or perhaps I am missing something?
Yes and deprecate and remove it from recommended. PR welcome. |
@urugator, if we set displayName after wrapping in memo, things gonna work (at first glance). But this looks a bit hacky Btw, i made a PR with docs edit and rule removal, check please |
When i wrap forwardRef by observer, any infomation that can be used as display name is lost.
For example:
So ObserverComponent has name ObserverForwardRef instead ComponentWithForwardRef.
If i explicitly set
i see same thing
The only variant ive found is to explicitly set displayName after wrapping in observer
but it isnt look pretty
Also, mobx/no-anonymous-observer is not happy with all of listed variants.
Any ideas?
Checked for mobx-react-lite: 3.4.0
Here: https://codesandbox.io/s/condescending-glade-yx3qgy?file=/index.js
The text was updated successfully, but these errors were encountered: