Tanstack Start: using <style> tag in <Head> in __root.tsx
file causes duplication lead to Uncaught Error: Hydration failed because ...
#2587
Unanswered
Foxeye-Rinx
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
The duplication leads to:
Context:
I just finished the walkthrough of Tanstack Start and trying to add a 404 page with some tailwind styles.
I noticed that the HTML is the first thing that is transferred to the browser. Then
client.tsx
andapp.css
come after.It causes a noticeable FOUC issue because the CSS comes later.
The common solution:
I searched the internet and the common solution is just to hide the
html
with CSS in<head>
likeAnd then remove it after the app.css is loaded.
My RootDocument
The
app.css
file load just after the NoutFound component's html (/1243421
returns not found component )My
app.css
The whole code:
https://github.com/Foxeye-Rinx/TanstackStartWithDuplicatedTags
More information:
https://youtu.be/mWK3Y_1kmaM?t=30628
is:inline
directive is an approach that allows me more control over how I can handle this FOUC issuehttps://docs.astro.build/en/reference/directives-reference/#isinline, Astro removes the <style> tags and bundle it to external files, using
is:inline
is to keep the <style> tag stick to the original HTML, it's a flag to tell the bundler that should not touch to this tag.Beta Was this translation helpful? Give feedback.
All reactions