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.
This commit is contained in:
+12
-2
@@ -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 (
|
||||
<QueryClientProvider client={queryClient}>
|
||||
<AppShell />
|
||||
</QueryClientProvider>
|
||||
);
|
||||
}
|
||||
|
||||
function AppShell() {
|
||||
const navigate = useNavigate();
|
||||
const location = useLocation();
|
||||
const giocatore = useGiocatoreBase();
|
||||
@@ -183,7 +193,7 @@ function RootComponent() {
|
||||
}
|
||||
|
||||
return (
|
||||
<QueryClientProvider client={queryClient}>
|
||||
<>
|
||||
<div className="mx-auto min-h-screen max-w-md bg-background pb-24">
|
||||
{/* Required: nested routes render here. Removing <Outlet /> breaks all child routes. */}
|
||||
<Outlet />
|
||||
@@ -191,6 +201,6 @@ function RootComponent() {
|
||||
{!isBenvenuto && <BottomNav />}
|
||||
{!isBenvenuto && <CelebrazioneBadge />}
|
||||
<Toaster position="top-center" duration={3500} closeButton />
|
||||
</QueryClientProvider>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user