-
Notifications
You must be signed in to change notification settings - Fork 48k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
classList wanted #309
Comments
+1 As another option, we could just accept array as a value for |
At FB we use this function https://github.com/facebook/react/blob/master/src/vendor/stubs/cx.js It can be used like this:
We've found that this is a much more declarative and succinct way to build up a CSS class list. GIve it a try and see how you like it. We've been chatting on and off about baking this functionality into React somehow but we hate the |
@petehunt thanks, that's exactly what I need. Though it still can be cool if |
Pre-open source we had a |
I agree with @andreypopp, class could accept either a string or an object in that format, that would be useful. Just for the reference, Angular's |
We also have an internal transform step, that turns this into a fast string concatenation, without spending an object allocation: something like:
The elegance in that transform is that it is not required - the runtime version of |
classSet is now available as React.addons.classSet (not inlined at transform time, but is otherwise good). |
I'm going to say we should stay away from this for now and just use helpers (like the one @spicyj mentioned now exists) |
Adding a
classList
property on included components synchronised withdomNode.classList
would be nice to have. Now that I think about this it's the same as<div class={' '.join(classList)}>
, but it will look much cleaner, don't you think?The text was updated successfully, but these errors were encountered: