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

Make <Head /> the last element rendered by <App /> to fix CSS-in-JS libs such as Stitches #11

Closed
louisremi opened this issue Apr 2, 2023 · 1 comment

Comments

@louisremi
Copy link

Stitches isn't easy to setup with Remix. I found out this article which helps, but provides an inferior workaround to the hydration problems this repo is solving.

Your solution also makes Stitches easier to use with Remix… provided that the <Head /> tag be rendered as the last element of the <App />

export const Head = createHead(() => {
  return (
    <>
      <Meta />
      <Links />
      <style id="stitches" dangerouslySetInnerHTML={{ __html: getCssText() }} />
    </>
  );
});

export default function App() {
  return (
    <>
      <Outlet />
      <ScrollRestoration />
      <Scripts />
      <LiveReload />
      {/* Head must be rendered after the rest of the DOM when using a CSS-in-JS lib such as Stitches */}
      <Head />
    </>
  );
}

My advice is to update the position of <Head /> in the docs

@Xiphe
Copy link
Owner

Xiphe commented Apr 3, 2023

That's interesting indeed! Thanks for reporting!

I added a note about this in the documentation. Will consider updating the code examples when it turns out to be required for other libraries, too.

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