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 possibility to build classname based on string

See original GitHub issue

I would really like the possibility to build a class name from a variable if the said variable is set. I encountered the issue when building classes for a standard Bootstrap alert box: in addition to the class alert I also needed the string alert-<alert-type>, but only if alert-type is defined.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:9

github_iconTop GitHub Comments

1reaction
ojamecommented, Jul 27, 2015

We’re using ES6’s computed values (Babel, of course):

{
   [styles.Bar]: true,
   [this.props.className]: this.props.className,
}
0reactions
dcousenscommented, Jul 28, 2015

@ojame of course, @oleronning this is definitely the way to do this. Lets not over-complicate this module with what is essentially a language hitch.

Thanks @ojame

Read more comments on GitHub >

github_iconTop Results From Across the Web

Create an instance of a class from a string - Stack Overflow
I'm trying to imagine a scenario where creating the object via class name and then casting it as that type would make any...
Read more >
Best way to new up a class with only classname as a string
I know I can build a switch off of the model name, but in this case I'm hard coding the method to known...
Read more >
The Basics - Manual - PHP
A class can inherit the constants, methods, and properties of another class by using the keyword extends in the class declaration. It is...
Read more >
Java.lang.Class class in Java | Set 1 - GeeksforGeeks
The above statement creates the Class object for the class passed as a String argument(className). Note that the parameter className must be ...
Read more >
How to Get Class Name in Python? - FavTutor
Another method is to use the type() method which is the in-built python method to find the type or the class name of...
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