Comments (20)
SOLUTION: Note to myself and others: don't forget to import styled from:
import { styled } from "../styles/stitches.config";
Thank you sir! 🎉
from examples.
I only experience FOUC with devtools open in firefox. If it's closed, FOUC goes away. In chorme, the font is a little jumpy with dev tools open but no flash. Nothing with devtools closed.
from examples.
I came across this also using Streaming + Remix + Tailwind. No idea if related, but I also noticed that
it does a FOUC when devtools are open (Chrome).
from examples.
Here's a link to the second method where I'm still getting FOUC: coreybruyere/california-custom-tile#2
from examples.
I followed the guide and also got FOUC.
the server does render some styles. but not the styles used in my Container and Title component added in the Index.
On client it goes ok.
On server it has following html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta content="noindex" name="robots" />
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Montserrat+Alternates:wght@400;500;600;700;900&family=Montserrat:wght@400;500;600;700;800;900&display=swap" />
<style id="stitches">
--sxs {
--sxs: 0 t-ioutRf
}
@media {
:root,
.t-ioutRf {
--colors-thaicello: #97e367;
--colors-limoncello: #fee62e;
--fonts-montserrat: 'Montserrat', sans-serif
}
}
--sxs {
--sxs: 1 ZocxG
}
@media {
body {
margin: 0;
padding: 0
}
}
</style>
</head>
<body>
<div class="c-eWbzaK"><img src="/build/_assets/thaicello-logo-QMORX73B.png" alt="" class="c-fDIUPu" />
<h1 class="c-fciIaC">Coming soon: Thaicello</h1>
</div>
Which does not contain c-eWbzaK for example
https://github.com/daphnesmit/thaicello for reproduction
visually at : https://thaicello.netlify.app/
I am almost thinking maybe its because of the Netlify setup I use.
EDIT: yep if I use the remix app server or the --template stitches it works...
Will investigate a but further with an empty netlify setup and copy pasting again and compare versions of pkgs.
EDIT2: weirdly enough in a new copy pasted setup it does work... no idea what the difference is.
SOLUTION: Note to myself and others: don't forget to import styled from: import { styled } from "../styles/stitches.config";
from examples.
In your HTML I can see your empty style tag:
<style id="stitches"></style>
You have two options:
- Do a double
renderToString
of theRemixServer
component inentry.server.tsx
. The first render doesn't get used, but it allows Stitches to collect all the styles to inject in the second render. - After your
renderToString
inentry.server.tsx
, replace the empty style tag HTML with a new style tag that contains the results ofgetCssText()
, as shown here.
from examples.
Thanks @tshddx - I tried the second option without any success. Any examples of the first option? Tried it, but want to ensure I'm rendering twice correctly. I'll try to link to a branch later today.
from examples.
@daphnesmit what do you mean by --template
? I haven't been able to fix this FOUC issue - as seen here: (https://california-custom-tile.netlify.app/). My latest attempt at a fix can be found here: coreybruyere/california-custom-tile#2
from examples.
I already did a fresh copy paste and there it worked. Dont really know what what the issue was.
you're repo is probably private because I get a 404.
I managed to get it to work. The thing that I find interesting is that both the example from Stitches & the example from Remix work but they are both different:
stitches: https://github.com/jjenzz/remix-stitches/blob/main/app/entry.client.tsx
remix example: https://codesandbox.io/s/github/remix-run/remix/tree/main/examples/stitches?file=/app/entry.client.tsx
The difference is the provider + context; In remix example they do a reset on the client.
I am wondering if that is needed or not: https://codesandbox.io/s/github/remix-run/remix/tree/main/examples/stitches?file=/app/root.tsx
from examples.
@daphnesmit I made my repo public. Saw your repo was private too. To get yours working did you follow the stitches example or the remix example? Going to try fixing later today. I couldn't get the codesandbox examples working.
from examples.
@coreybruyere its is working i probably made a dumb mistake. Just wondering why they are both different. I made mine private again indeed
from examples.
@daphnesmit are you running netlify dev
as your dev script?
from examples.
Just for reference as it's not really visible at the moment, Stitches seems to be in maintenance only mode and won't get new features according to https://www.modulz.app/blog/modulz-acquired-by-workos
from examples.
This is also an issue in Astro, and makes Stitches unusable :(
from examples.
Has anyone used stitches while using renderToPipeableStream
? How am I able to replace something in a stream 🤔
from examples.
You might be able to use a PassThrough
and a Transform
but I think there might be various ways of taking it all the way, one might be to buffer to memory cause don't know if you can give stitches stream chunks 🤷♂️
entry.server.tsx
import { PassThrough, Transform } from "stream";
import { renderToPipeableStream } from "react-dom/server";
import { RemixServer } from "@remix-run/react";
import { type EntryContext, type Headers, Response } from "@remix-run/node";
import isbot from "isbot";
const ABORT_DELAY = 5000;
export default function handleRequest(
request: Request,
responseStatusCode: number,
responseHeaders: Headers,
remixContext: EntryContext,
) {
const callbackName = isbot(request.headers.get("user-agent")) ? "onAllReady" : "onShellReady";
return new Promise((resolve, reject) => {
let didError = false;
const { pipe, abort } = renderToPipeableStream(
<RemixServer context={remixContext} url={request.url} />,
{
[callbackName]() {
let body = new PassThrough();
const transformStream = new Transform({
transform(chunk, encoding, callback) {
console.log("entry.server", chunk.toString());
callback(null, chunk);
},
});
responseHeaders.set("Content-Type", "text/html");
responseHeaders.set("Transfer-Encoding", "chunked");
responseHeaders.set("Connection", "keep-alive");
resolve(
new Response(body, {
status: didError ? 500 : responseStatusCode,
headers: responseHeaders,
}),
);
pipe(transformStream).pipe(body);
},
onShellError(err) {
reject(err);
},
onError(error) {
didError = true;
console.error(error);
},
},
);
setTimeout(abort, ABORT_DELAY);
});
}
from examples.
FYI Stitches has largely been abandoned by original contributors and development has dramatically slowed down. I've moved back to SCSS for projects but have my eyes on vanilla-extract.
from examples.
@coreybruyere did you see that we just added an example for vanilla extract? 👀
from examples.
Closing this stale issue.
from examples.
@richardanewman Good catch, when I close the dev tools there's no more FOUC
from examples.
Related Issues (20)
- Blog tutorial needs update of routing HOT 4
- Blog Tutorial uses Route File Naming (v2) HOT 1
- Material UI example is broken HOT 1
- _official-realtime-app example is buggy HOT 3
- Using template as specified does not seem to work HOT 4
- Infinite scrolling example seems to be broken in codesandbox
- Emotion example is outdated HOT 2
- Cookie but missing user in db, ends up being a promise and not redirecting to login HOT 2
- [Feature Request] Framework user wants to have an example integration with Cloudscape Design System HOT 1
- _official-realtime-app Concurrent connections HOT 1
- tailwind styles are not processed in v1.19.2 but are in v1.19.1 HOT 1
- chakra-ui example has hydration issues HOT 2
- Stitches example: Greedy regexp pattern potentially breaks markup HOT 1
- MSW example not working HOT 1
- mdx-bundler example
- Example for Vite + Styled Components?? HOT 1
- Vite + Styled Components Example HOT 4
- Create an example of an app with nested routes
- nprogress uses useTransition, should it use useNavigation instead? HOT 2
- Feature: Pocketbase Auth Example with Realtime Data
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from examples.