[request] Example without usage of a boilerplate kit, css-modules or withStyles
See original GitHub issueI’ve been going through the code and tried to source help on the Discord Reactiflux website to see if I could take the example usage provided and make it work with my own server setup : https://github.com/JaxCavalera/Tagged_Isomorphic/blob/master/src/server.jsx
The most challenging lines to follow are specifically related to :
const context = { insertCss: (styles) => css.push(styles._getCss()) };
I don’t really understand the purpose of using that variable and I’m unsure of where the styles variable is being defined or how it ends up being an object with functions such as _getCss().
Will isomorphic-style-loader work without the use of the withStyles Higher order function or is that a dependency module that needs to manually be imported and used in each of my components… which would seem to then signify that I need to also use css-modules so that makes 2 dependencies.
I’m not very clear on css-modules and what benefit it brings to the table.
Issue Analytics
- State:
- Created 8 years ago
- Comments:12 (3 by maintainers)
Top GitHub Comments
1. In contrast to the style-loader, isomorphic-style-loader allows you to use the same webpack configuration for CSS in server and client bundles.
ISL just adds to required/imported styles this two methods:
styles._getCss()
- isomorphic method which returns CSS string, can be run on the client and on the server.styles._insertCss()
- client-side only method, allows inject your CSS into the DOM.Example of a simple one-page application:
2. ISL does not force you to use CSS Modules, you can use any other loaders together with ISL.
It is also useful to look at the css-loader documentation to see how to disable the css-modules.
Example of webpack configuration for styles:
3. To understand the benefits of using CSS Modules, please read this article:
4. ISL allow you to render “critical CSS” on the server, during server-side rendering (SSR). Read more about this feature:
So for critical CSS server must send to the client only the styles that are needed for visible html-elements. React provides an excellent component model with lifecycle that makes it easy. The only thing you need to do is somehow to collect the styles for rendered components.
You can write your own critical css collector:
Or just use ISL withStyles helper.
Thanks for that link! I don’t understand what you mean when you say
How’s the fork different from this one?