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

FOUC solution based on radicalpi's implementation #133

Closed
wants to merge 4 commits into from
Closed

FOUC solution based on radicalpi's implementation #133

wants to merge 4 commits into from

Conversation

IntusFacultas
Copy link

Hi there, this expands on the idea implemented by @radicalpi in #112 by fixing the double injection issue where the server side rendered CSS gets loaded as well as the style tags that are thrown into the during runtime. I've also refactored the logic they wrote for setting up the server side rendering into a mixin that can be used.

I've tested this with a fairly simple Nuxt project which I've uploaded to a repository here, and I seem to have managed to fix the double injection issue they mentioned.

Here is a screenshot of the element inspector, you'll notice there's only one vue-styled-components style tag
image. The other style tags below it are Nuxt specific style tags.

The way I foresee this being used can be seen in pages/index.vue, but I'll share the code here for convenience:

import { StyleSheet, ServerSideRenderMixin } from 'vue-styled-components';
StyleSheet.serverRendered = true;

export default {
  mixins: [ServerSideRenderMixin],
}

@IntusFacultas
Copy link
Author

This pull request is meant to address the issue in #52 forgot to mention

…led-components into fix-double-injection-and-refactor-into-usable-mixin
@IntusFacultas
Copy link
Author

I've fixed the merge conflict

@IntusFacultas IntusFacultas closed this by deleting the head repository Feb 2, 2023
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

Successfully merging this pull request may close these issues.

2 participants