CSS-in-JS Rendering Hooks
See original GitHub issueš„ Proposal: Hooks for CSS-in-JS Client and Server Rendering
- Guides / Styling and Layouts ā Styling components with CSS-in-JS frameworks
So, the [v2] āļø Umbrella issue for v2 docs has the above open TODO (although the issue has been closed); and this is also currently mentioned in the docs as āwelcoming PRsā.
I have some experience with the setup patterns for emotion
(incl. v11) and styled-components
here, and would like to help with this. As far as I can tell from the source, this would require additions to the Lifecycle APIs so that the serverEntry.js
and clientEntry.ts
filesā rendering functions could be modified. I would need some guidance on creating these hooks.
Anyone want to help me get started?
Issue Analytics
- State:
- Created 3 years ago
- Reactions:7
- Comments:24 (5 by maintainers)
Top Results From Across the Web
JSS integration with React
React-JSS integrates JSS with React using the new Hooks API. ... Critical CSS extraction - only CSS from rendered components gets extracted.
Read more >[react-jss] Investigate on how to support the new React hooks
We will create a prototype here: https://github.com/cssinjs/react-jss-hook and merge this into react-jss once the hook is stable enough andĀ ...
Read more >cssinjs/Lobby - Gitter
If your functional components get too complex, you can move out hooks. Your business logic doesn't need to be defined in your render...
Read more >Component-level CSS-in-JS - Ant Design
... component style will be regenerated during the rendering phase. ... @ant-design/cssinjs has a performance advantage whether it is theĀ ...
Read more >Styling: CSS-in-JS - Next.js beta docs
A style registry to collect all CSS rules in a render. The new useServerInsertedHTML hook to inject rules before any content that might...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hey guys,
I found a super hacky way to collect styles for
styled-components
, and I do not recommend it to anyone, but it works š.Most likely, it breaks hydration and forcing react to re-render the whole tree. Sadly, I donāt know how to force the non-production build to check, but honestly, this is much better than FOUC.Iām voting for public API, which will allow returning your element before passing it to
renderToString
fromreact-dom/server
.Hacky way
children
:Root
:UPD: Fixed
DocusaurusContext
imports UPD (2022-05-06): No longer works for v2.0.0-beta.16+ UPD (2022-06-10): Fixed for v2.0.0-beta.21+ thanks to @EmaSuriano!@bennodev19 thatās something we want to work on but is not so simple. APIs are forever so weād rather find a good abstraction for CSS-in-JS integration that will work for all the libs, not just SC. We could copy Gatsbyās abstraction but itās also a good time to study what has worked well and not so well for Gatsby by studying all its CSS-in-JS plugins a bit.
Youād rather convert to css modules if you cannot wait because I donāt think we should rush on implementation without a careful design.