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.

Ability to inject and retrieve class name

See original GitHub issue

Some 3rd party react components allow user to customize their css via className property. I want to create the css class in kotlin-styled and then put the name of that class into custom component.

I’ve not found a good way to do this. At the moment I’m doing it like this:

object A  : StyleSheet("A", isStatic = true) {
    val B by css { ... }
}

I’m manuallying using A-B name and I also have to manually inoke this method to make sure it is added to css via A.B.invoke(CSSBuilder()).

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
matejdrocommented, Apr 13, 2020

Right, but I don’t want to use this in any kotlin css statement. I just want to use it in custom component that only accepts className

0reactions
Leonyacommented, Apr 13, 2020

It’s done like this:

css {
    +A.B
}

Where css is an extension function of StyledBuilder<*>, CustomStyledProps, or <P : CustomStyledProps> RElementBuilder<P>

Read more comments on GitHub >

github_iconTop Results From Across the Web

How can I get the class name from a C++ object?
I get 1A , but the class name is one . The site cppreference.com says "There is no guarantee that the same std::type_info...
Read more >
Using dependency injection in Java - Introduction - Tutorial
With this analysis it is able to create an instance of the class and inject the objects into the defined dependencies, via Java...
Read more >
Assigning a class dynamically from a class name string
When I want to access the custom method move() in Tiger, I use the as operator to access animal as a Tiger class....
Read more >
JavaScript adding a class name to the element - GeeksforGeeks
Using .className property: This property is used to add a class name to the selected element. Syntax: It is used to set the...
Read more >
How to Dynamically Add a Class Name in Vue
Adding a dynamic class name is as simple as adding the prop :class="classname" to your component. Whatever classname evaluates to will be the...
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