-
Notifications
You must be signed in to change notification settings - Fork 22
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
Inline Styles? #14
Comments
Interesting, it does look like a problem just waiting to happen. I'd definitely like to know if they have an argument why that's not the case. |
This was exactly what put me off React in the first place. I would love to get some more views on this. @nelsonic Worth sharing the question on twitter? |
@iteles nah, twitter is mostly people who are relatively inexperienced with large-scale react apps (e.g: have only built a handful of few components - still maintainable) and thus still think mixing style inside JS is a great idea ... and nobody at Facebook is going to badmouth anything about React because its their main front-end-developer recruitment tool ... we need to survey people who are attempting to _maintain_ a React web app that was built & deployed by someone else ... I have personal experience of attempting to Fix other people's poorly implemented React components (no names) ... but I don't know if my experience is "anecdotal" or if others have worked on apps that are large enough (and built by enough different people with insufficient testing) to be un-maintainable ... |
This is actually an interesting article that doesn't advocate inline styling but does go some of the way to explaining the reasoning for this to be part of react in the first place: https://medium.com/@ajsharp/please-please-don-t-use-css-in-js-ffeae26f20f#.pypeemetl |
http://red-badger.com/blog/2015/11/19/london-react-meetup-november-2015/ |
Dunno if anyone has seen this yet, but looks cool ---> https://github.com/rofrischmann/fela Based on 'atomic' css, a la http://acss.io (i think) |
Hi @newswim However, we decided to use We know it's not everyone's "cup-of-tea" because ironically it requires some CSS knowledge (even though you are not using CSS directly when you use Tachyons you still need to know about Margin, Padding, Positioning, etc. in order to use the library...) Where "Atomic" CSS is designed for "Maximum Re-use", see: https://github.com/acss-io/atomizer There are still plenty of use cases for the various CSS Frameworks/Libraries/Systems, Anyway, thanks for sharing the link to |
Except for JS based animations, I would never write CSS in JS. We have LESS/SCSS with PostCSS for that. I think it in terms of operation that Browser needs to perform to apply any change. And when a Style is added by JS, there is DOM manipulation which puts all the core parts of browser to work for each step. With CSS, these operations happen in less number (I assume). |
@pankajpatel exactly. That is not to say that we don't apply styles in our We will be producing an intro video to Tachyons 🔜 dwyl/book#69 (watch this space) Thanks again for unearthing this issue/discussion thread! 👍 |
Thanks @nelsonic for info about Tachyons. This seems to be a good fit for kick starting new projects. I found many kickstart projects for React and many were good fit, but I have to do the CSS setup most of the times. So I created one just for myself https://github.com/pankajpatel/kickstart-react. It allowed me to choose between LESS and SCSS with just config file , but I thing I will add Tachyons as primary one in there. |
I came across a thread about the Browser Performance in Mobile devices, which primarily stated that JS animations on mobile screens will lag because as part of optimising Battery Utilisation, browser pauses the JS execution while scrolling whereas CSS isn't. It sounded fair too for mobile browsers. And now I'm thinking what would happen to CSS in JS. |
@pankajpatel That's interesting! I hadn't at all thought of the introduction of lag due to JS runtime behavior on mobile. Thank you's to yourself and @nelsonic for the illuminating discussion. I stumbled across this how-to-style-react article yesterday and felt utterly lost. It seems like Picking a library seems conditional on the use case, but all the divergent opinions (not from you folks) seems a bit at odds with the whole point of a front-end framework. While I'd like to use SCSS for all of the familar libs and functions, I can definitely see the gains from an extremely declarative library like Tachyons. Here it goes... 🏊 |
Styled-Components are about to published a really cool utility library called Polished. If anyone used Stylus and remembers Rucksack or Nib, it reminds me of similar mixins. It seems to play very nicely with the larger Styled Components workflow. I know DWYL is partial to Tachyons, but this is one of the few React styling libraries that looks like it will be successful in the long term. |
@newswim it's always good to be aware of what is available. thanks for sharing it! 👍 However ... I think I'm not an "expert" but ... each time I see a style library that requires ES6 I cannot help but feel it is (almost by definition) over-complicating UI rendering in the pursuit of "moar features". More importantly what are you/your team using for your UI and why? 🤔 |
The article by Addy Osmani published few days back explains clearly the initial peroformance load in JS frameworks. What would happen if CSS also becomes part of that initial loading? More time needed to respond after initial load. BEM and similar methodologies already are there to easily manage the CSS' meaningfulness regarding the components. |
@nelsonic my team just started using a combination of The syntax is a little daunting at first (literally put all these together today), but it should help greatly with creating a theme (the why question). 😸 |
Facebook officially recommends that people define their
style as a JavaScript Object: http://facebook.github.io/react/tips/inline-styles.html
e.g:
Does anybody else think that in-lining styles as JS inside Components is a _debugging nightmare_ waiting to happen (*as an app gets larger and new people add hacks & overrides to mask previous CSS instead of editing the CSS in the style sheet...?
The text was updated successfully, but these errors were encountered: