Skip to content
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

extractCss() returns empty string in Solid SSR environment #495

Open
viridia opened this issue Oct 26, 2022 · 2 comments
Open

extractCss() returns empty string in Solid SSR environment #495

viridia opened this issue Oct 26, 2022 · 2 comments

Comments

@viridia
Copy link

viridia commented Oct 26, 2022

Here's an example demonstrating the problem:

https://stackblitz.com/edit/solid-start-bare-ts-g7hiuv?file=src/routes/index.tsx

I'm only using css() for this demo, not styled().

I am generating the <style> element using the following code:

<style id="_goober" innerHTML={extractCss()}>{' '}</style>

If you examine the HTML response in the network tab, you'll see that the <style> element for goober is empty, even though I am using extractCss() to generate the content.

The styles look correct once goober has had a chance to render them on the client side, but there is a flash of unstyled content.

I also tried this with another CSS framework - Stitches - and did not encounter this same problem - that is, the following code works as expected:

<style id="stitches" innerHTML={getCssText()}>{' '}</style>

...where getCssText() is the Stitches equivalent of extractCss().

@viridia
Copy link
Author

viridia commented Oct 27, 2022

It appears that the problem is because extractCss() is not idempotent. Each time the server gets called to render a page, extractCss() erases the previous styles. This is a problem because the styles were created as a result of static declarations which are only executed once. Hmmm.

@DennisHuallanca
Copy link

Hello I have the same problem, I have a module that uses extractCSS(), which works the first time we load the main page, but when we reload the content of the module extractCSS() returns an empty string.

<style id="_goober">{extractCss()}</style>

goober: version "2.1.13"
"react": "^18.2.0",

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants