ZopaPublic/react-components

Using .displayName for easier debugging

Closed this issue ยท 3 comments

Other component libraries add say InputText.displayName = 'InputText' for easier debugging as the name of the component will be included in the rendered result. Maybe a thought for this library?

@grabbeh good catch ๐Ÿ’ฏ

Currently, even when using styled-components, we're wrapping them with a named function, which preserves the name on the component during errors:

Screenshot 2019-06-07 at 11 18 48

and when debugging using the react-devtools:

Screenshot 2019-06-07 at 11 09 53

However, maybe using displayName is a more standardised practice and would avoid us an extra wrapper on the rendered component ๐Ÿ’…๐Ÿป

What do you think @poteirard? I'm up for it ๐Ÿ’ช๐Ÿป

Ah serves me right for not using react-devtools. I leave the decision in your capable hands (and I'll turn on react-devtools!).

React's documentation kind of implies you don't need to add it, but if you are specifically wrapping just to add a debuggable name - I'd argue displayname is a better fit.