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.

Add `className` prop to all components

See original GitHub issue

Relying on class names is brittle, risking typos (or making string constants necessary) and opening up an escape hatch to meddle with the insides of components. It is better to remove className props entirely and rely on emotion component-based styling instead.

After running into some tricky-to-debug styling errors using the components, the scope of this PR has changed. Read along 😃

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
fabien0102commented, Jul 9, 2018

I think that we can try this pattern for our module -> https://github.com/pedronauck/docz/blob/master/examples/typescript/src/components/Alert.tsx

So we retrieve all native react props (including classname), and it’s pretty 😎

1reaction
TejasQcommented, Jul 6, 2018

I’m totally in favor of allowing a className prop everywhere. I think it makes sense for components to receive classNames all the time, but not ad-hoc css styles.

Good catch, Peter!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Passing in class names to react components
Shouldn't adding className prop to a React component pass on that className to the first container element instead of passing it as a...
Read more >
Pass class names as props to React components
Pass a string containing the class names as a prop. · Destructure the prop in the child component. · Assign the class names...
Read more >
Passing className to components in React
In React, we are familiar with the concepts of a className on components. It's the way React adds the class attribute to an...
Read more >
Passing className to components in React
Passing Classnames as props in React. In all honesty, I probably made it sounds like it was going to be very complicated, right?...
Read more >
Passing classnames as a props to the React component
In this tutorial, we are going to learn about how to pass the classnames as a props to the react component.
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