question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Improving styled-components class names for debugging

See original GitHub issue

Task Description

Re-sharing feedback from https://github.com/GoogleForCreators/web-stories-wp/pull/11737#discussion_r901929974:

I understand and agree with your point about consistency. This may be more of a concern related to the patterns required to use Styled Components than anything specific to this project.

A lot of the classNames generated by Styled Components can be redundant and hard to track up the component tree. For example, classNames like components__Container-sc-xxxxxx and components__CardWrapper-sc-xxxxxx are generic and lose meaning because they’re repeatedly redefined in components to accommodate the patterns required for composition using the Styled Components library.

Going up the component tree offers a little context, but navigating the codebase to find specific instances of general-use components isn’t obvious (maybe just to developers new to the codebase and patterns used, myself included).

Additional Context

Related links:

https://styled-components.com/docs/tooling#better-debugging

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:2
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
barklundcommented, Jun 20, 2022

"meaninglessFileNames": ["index", "styles"]

This looks like a great option to use. We sometimes have our S-C components in a single file named components.js or styles.js, so this would make their debuggable names more traceable.

0reactions
spacedmonkeycommented, Jul 4, 2022

I updated the babel config and not seeing see any change in markup / class.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Control Class Names in Styled Components
styled -components is a popular library to style React applications. ... Hopefully, the recognizable class names make your debugging easier.
Read more >
Tooling - styled-components
Better debugging. This option enhances the attached CSS class name on each component with richer output to help identify your components in the...
Read more >
Readable Classnames with Styled-Components - Medium
Hopefully this short article makes debugging a little easier for those of you that use styled-components, i highly recommend using the vscode ...
Read more >
More meaningful/semantic class names during development ...
And it really causes problems while debugging. ... Is it possible to use class names similar to styled components names.
Read more >
How To Make Styled Components Class Names Readable
As the class names of your styled components are generated , even attempting to debug them can be a nightmare. Fortunately, there is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found