-
-
Notifications
You must be signed in to change notification settings - Fork 981
Start hydration issue with localized head meta title using Lingui i18n #4279
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
Comments
does this still exist on the alpha branch? |
I haven't been following the alpha branch, I can't quite get it to start, EDIT: Ah I saw the examples at https://github.com/TanStack/router/tree/alpha/examples/react/start-basic but I'm not seeing a way how to do custom client/server initialization |
checkout #2863 (comment) |
Sorry I'm a bit confused how import { i18n } from "@lingui/core";
import {
createStartHandler,
defaultStreamHandler,
defineEventHandler,
} from "@tanstack/react-start/server";
import { createRouter } from "./router";
import { setupLocaleFromRequest } from "./modules/lingui/i18n.server";
export default defineEventHandler(async (event) => {
await setupLocaleFromRequest();
return createStartHandler({
createRouter: () => {
return createRouter({ i18n });
},
})(defaultStreamHandler)(event);
}); Also how do I customize the
|
have a look at our e2e example on how server and client can be customized https://github.com/TanStack/router/tree/alpha/e2e%2Freact-start%2Fbasic%2Fsrc |
That link doesn't help at all, The docs here (I found it on X): https://tanstack-com.vercel.app/start/latest/docs/framework/react/server-routes#handling-server-route-requests mention a I'm not 100% sure if the approach in Lingui's repo is the best solution to this problem, but basically I'd like to execute some logic on every route in the app, server side, based on the request headers. That might affect how router is rendered and might be async. How do I do that? |
@paolostyle what exactly do you need to execute here? is this inside of react? |
For now I'd like to just make the code posted in OP's last comment work: import { i18n } from "@lingui/core";
import {
createStartHandler,
defaultStreamHandler,
defineEventHandler,
} from "@tanstack/react-start/server";
import { createRouter } from "./router";
import { setupLocaleFromRequest } from "./modules/lingui/i18n.server";
export default defineEventHandler(async (event) => {
await setupLocaleFromRequest();
return createStartHandler({
createRouter: () => {
return createRouter({ i18n });
},
})(defaultStreamHandler)(event);
});
At the moment it does not work, because of TypeScript error For essentially the same reason e.g. |
Uh oh!
There was an error while loading. Please reload this page.
Which project does this relate to?
Start
Describe the bug
When using the Lingui i18n localization + TanStack Start template, when trying to use a localized meta title the page hydrates weirdly.
Before hydration, the SSR render is all correct. The page title is localized and the content is correct.
After hydration, the contents appears twice, the top appears to be the SSR version (clicking links will load pages), the bottom appears to be the hydrated client (clicking links do not load pages). The localized title also does not work because there are two
<title>
in the HTMLThere are also no hydration errors in the console.
Your Example Website or App
https://codesandbox.io/p/devbox/nice-snowflake-yrx273?file=%2Fsrc%2Froutes%2Findex.tsx%3A3%2C1-4%2C42&workspaceId=ws_62aAsWkSzvrQC9UJ9wAyfv
Steps to Reproduce the Bug or Issue
Expected behavior
The page to be hydrated correctly, no double up.
The page title to be localized.
Screenshots or Videos
SSR before hydration
After hydration
Platform
Additional context
No response
The text was updated successfully, but these errors were encountered: