-
Notifications
You must be signed in to change notification settings - Fork 194
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
Breaks child.type comparisons #54
Comments
Proved this happens with a failing test on branch |
This is actually not surprising. Currently we track how a functional component changes by substituting it with another functional component that tracks props and renders the original functional component. The type of any component that is rendered with "whyDidYouRender" enabled on it is indeed "WDYRFunctionalComponent" (instead of the expected "MenuItem" in this case). A deep refactor is needed to deal with it- we need to somehow get access to every render of a Component's instance (React element) without substituting it with another one. But- I consider this an edge case though because child.type is not documented (as far as I can tell) and no one should rely on it anyway, so it's a low priority for me. (Can be interesting to solve though) |
A workaround (not a very satisfying one, I know) is to use child.displayName === MenuItem.displayName |
Perhaps the type getter could be monkey patched to return the type of the child if type is called on a WDYRFunctionalComponent wrapper. |
I tried it. This can't be done. the type getter is strictly read only :( |
This will always return an empty array when activated:
Is there a way to get this module to work with child.type comparisons? Thank you.
The text was updated successfully, but these errors were encountered: