2 ms·
I've recently started keeping my CSS together with the UI components that I create in React. Essentially doing what is being advocated here: https://speakerdeck
by Rezo 11y ago
I've recently started keeping my CSS together with the UI components that I create in React. Essentially doing what is being advocated here: https://speakerdeck.com/vjeux/react-css-in-js https://speakerdeck.com/vjeux/react-css-in-js
It defies existing good practices, but once I tried it I quickly realized that things that are tricky in CSS are mostly trivial in JS (namespacing, dependencies, code elimination / minification, isolation, constants, the whole tooling in general etc.). As a programmer and not a designer, I also find it easier to reason about JS.
You end with something that looks very much like Web Components, but fully usable right now. In practice it means you can add a 3rd party component with "import TimePicker from 'material-ui/timepicker'", slap a <TimePicker/> into your JSX and you're done. See http://material-ui.com/ http://material-ui.com/ for a complete toolkit of React components created this way.