-
Notifications
You must be signed in to change notification settings - Fork 2.5k
react-css-modules interest? #655
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
Comments
+1, it looks promising and less restrictive. |
+1 |
1 similar comment
+1 |
Here is where it stands right now. There are issues with hot-reloading and error handling (probably other things too). I am not sure it is worth the added complexity, although I am sure the current issues can be fixed. Thoughts? |
+1 |
@chrisblossom Can you explain a bit about your thinking there? I wasn't expecting the changes of adding ExtractTextPlugin and webpack-isomorphic-tools without its development switch on. Also, is browser-sync necessary? Aren't styles hot reloading without it? |
@bdefore When I put this into my personal project I thought I had tried it without the ExtractTextPlugin, but I think I must have just been following directions from the module's readme. The changes to webpack-isomorphic-tools (which were partially a temporary hack) and the addition of browser-sync were due to adding ExtractTextPlugin. Much cleaner and seems to work so far: |
I've been trying it out and it still doesn't gracefully work with hot reloading. Often I have to manually refresh the page if the CSS class wasn't there prior. |
The client and server consistently get out of sync, which (now that I am seeing this again) is why I went to using the ExtractTextPlugin as the module suggested.
|
Personally I prefer webpack's local styles without the react-css-modules layer. Main concern is that references to class names go from code (javascript variable) back toward config (custom parsed string). Which of the problems it solves do you guys find most compelling? |
@kaploink I was bothered by having to go against the standard css-naming convention. I personally reverted back to not using this module and having a bit uglier code using {styles['css-naming']}. If anyone is wanting to use react-css-modules in the future, #693 is the base for getting it to work. Going to close this for now. |
Hey, sorry to comment on such an old issue, but I'm wondering if anyone ever successfully got |
@isaachinman have you considered using just standard css modules, as implemented by webpack's css loader? It's designed to work with react out of the box, and is already set up in this repo. Radium vs react-css-modules is interesting; they're at pretty extreme ends of the spectrum. Might want to look at some others between, such as aphrodite or JSS. Here's a great summary of the best current options: https://github.com/oliviertassinari/a-journey-toward-better-style. Also I think there's recently been a bit of a shift away from css-modules in light of create-react-app deciding to not support them without ejecting. This issue is what led to one of the css modules creators making and using styled components instead (css in js). Personally I'm using Radium at the moment, as highest priorities for me are pure js object composition (rules out css modules) and small inline chunks of style (rules out aphrodite/jss, etc). Downsides of perf hit for repetition in style tag (~25%) and maybe some issues with SSR seem worth the cleaner component composition ability. Watching closely what happens with MUI styling though, as they have a tonne of expertise in inline styling (currently heading toward JSS). |
Hey @kaploink. I guess they are rather extreme options. I have used Radium in previous projects and am (mostly) comfortable with its methodology. My only concern with Radium is pseudo selectors. I have no idea why one would elect to use JavaScript to replicate functionality that is already baked into all browsers. Can you explain what you mean by "repetition in style tag"? |
Hey @isaachinman, well the pseudo-selectors are just there to support what people are used to doing with css. Whether pseudo-selectors are the best way to track hover/active/etc state and associate that with certain styles is another question. I see them like many other css features - hacks that are handy for common cases, but not generic/pure enough to scale properly to all scenarios (e.g. :hover affect another element's styles). If it's behaviour/state then I think belongs in js, and styling should be purely to describe actual styles. Similar for media queries. Of course, performance considerations complicate things... Here's example js approach to hover styling (more testable) - boilerplate could be cut down a lot (arrow funcs, es7, maybe HOC): https://facebook.github.io/jest/docs/tutorial-react.html#snapshot-testing
As in "css in js" (aphrodite, jss, etc) store their styles in css classes associated with class tag, so can reuse them across similar elements and avoid styling duplication in the dom; whereas radium and pure inline styles just use the style tag and store all styles against all elements (repeat themselves more, bloating the dom and affecting some performance by ~25% apparently). |
Is there any interest in integrating react-css-modules into this kit? I can put together a pull request if so.
The text was updated successfully, but these errors were encountered: