You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm currently migrating my website to react-router v7 from react-helmet and I stumbled across this problem.
Situation
As of [email protected], attributes of <html> cannot be changed from a leaf route, making it difficult to set appropriate lang attribute in multilingual websites while reusing the same layout. This applies to <body> attributes as well, meaning <body className> cannot be modified once it is set in root.tsx.
Workaround
As a simple workaround, I could use useMatches to reflect the property set in a leaf route's handle.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I'm currently migrating my website to react-router v7 from react-helmet and I stumbled across this problem.
Situation
As of [email protected], attributes of
<html>
cannot be changed from a leaf route, making it difficult to set appropriate lang attribute in multilingual websites while reusing the same layout. This applies to<body>
attributes as well, meaning<body className>
cannot be modified once it is set inroot.tsx
.Workaround
As a simple workaround, I could use
useMatches
to reflect the property set in a leaf route'shandle
.app/route.tsx
:Suggestion
One of possible API change I came up with is something like this:
<HTML>
and<Body>
components, just like<Meta>
and<Links>
<Head>
as well, for the sake of completeness)meta
function'stagName
html
andbody
app/route.tsx
:app/routes/leaf.tsx
:Beta Was this translation helpful? Give feedback.
All reactions