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.

Possibility to use class-name property instead of className

See original GitHub issue

The problem

I created a tiny Emotion wrapper in ClojureScript. I’m going to open-source this wrapper but I have issue with className property. In Clojure idiomatic to use kebab-case notation. So, it would be great to use prop class-name in styled components instead of className but unfortunately I don’t have any methods in emotion to change it. Currently I have only one way, it’s wrap styled component to react.createElement and convert className to class-name.

Proposed solution

It would be great to add this to options (somethings like shouldForwardProp). For example,

{
  classNameProp: 'class-name',
}

Link to this wrapper (WIP) https://github.com/khmelevskii/emotion-cljs

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:18 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
Andaristcommented, Feb 8, 2021

Ye, I understand that it’s more annoying with React components but it still is not enough of an argument for me to accept this change. I understand that this has not played out like you would have hoped and I’m sorry for that.

0reactions
Andaristcommented, Sep 9, 2022

Yes, I use bare react and react doesn’t know anything about class-name, that’s why emotion-cljs replace all class-name to className and then pass it to bare react component. It looks like this example below (simplified version):

This looks like a suitable workaround.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why React uses className over class attribute
Explanation: The only reason behind the fact that it uses className over class is that the class is a reserved keyword in JavaScript...
Read more >
class vs className in React 16 - Stack Overflow
class is a keyword in javascript and JSX is an extension of javascript. That's the principal reason why React uses className instead of ......
Read more >
Why you have to use className in React, but not in Preact?
The only reason behind the fact that it uses className over class is that the class is a reserved keyword in JavaScript and...
Read more >
Why does React use className instead of a class attribute?
When applying CSS classes to all common DOM and SVG elements like buttons, li, a, and div in React, we use the className...
Read more >
Why do I have to use 'className' instead of 'class' in ReactJs ...
Because it is parsed by JavaScript, and JavaScript treats certain words as special, a few attribute names in JSX are different (className instead...
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