baobab-react
baobab-react copied to clipboard
Reverse displayName helper order to displayName || name
Hey, just a proposal on changing the order that displayName helpers in higher-order choose how to pick what the name of the Component is. Currently is is:
return Component.name || Component.displayName || 'Component';
This is normally fine when you have classes declared with the proper class names. However I'm actually passing an already wrapped class component that wouldn't have the .name set to anything specific, similar to how this is wrapping components. I am however setting the .displayName correctly on the component.
Looking at the mixin implementation of the displayName helper, it doesn't look like it would run into this issue.
Would it be possible to allow a PR or a change to reverse the order when finding the displayName for the new branched component to fix this?
Hello @basicdays. I don't remember exactly why but I think I chose this order initially because otherwise it was causing bugs on earlier versions of react. But I am not sure anymore. So I'll probably accept a PR. If you do so, can you however be sure to also check the mixin to see if something of the kind should also be done?
Awesome, yeah I can do an PR with the change. I'll double check the mixin as well.