From 7e93229eeed848a6cd442f5fe04c7ccb6bfb7bcb Mon Sep 17 00:00:00 2001 From: Davide Grilli Date: Thu, 3 Sep 2026 10:16:40 +0200 Subject: [PATCH] Sposta QueryClientProvider sopra AppShell per evitare crash SSR useGiocatoreBase() ora interroga giocatori_squadra con useQuery, ma RootComponent la chiamava prima di montare QueryClientProvider: ogni pagina falliva in SSR con "No QueryClient set". Il provider avvolge ora tutto fin dall'inizio; la logica di redirect/loading si sposta in un componente AppShell interno, comportamento invariato. --- src/routes/__root.tsx | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/routes/__root.tsx b/src/routes/__root.tsx index 666ca13..6b88bdb 100644 --- a/src/routes/__root.tsx +++ b/src/routes/__root.tsx @@ -157,6 +157,16 @@ function RootShell({ children }: { children: ReactNode }) { function RootComponent() { const { queryClient } = Route.useRouteContext(); + // `AppShell` legge la rosa da `giocatori_squadra` (useGiocatoreBase → DD-015): serve stare + // dentro il QueryClientProvider, quindi il provider avvolge tutto fin da qui. + return ( + + + + ); +} + +function AppShell() { const navigate = useNavigate(); const location = useLocation(); const giocatore = useGiocatoreBase(); @@ -183,7 +193,7 @@ function RootComponent() { } return ( - + <>
{/* Required: nested routes render here. Removing breaks all child routes. */} @@ -191,6 +201,6 @@ function RootComponent() { {!isBenvenuto && } {!isBenvenuto && } - + ); }