fix(app): hoist QueryProvider above PortalProvider so portaled sheets see QueryClient

@gorhom/portal renders children at the host's location in the tree, so
sheets portaled to the root host lost QueryClient context (crash:
"No QueryClient set" when opening provider diagnostic sheet). Reorder
RootProviders and document the invariant: PortalProvider stays innermost.
This commit is contained in:
Mohamed Boudra
2026-05-09 11:04:38 +07:00
parent 1042270298
commit 832a2031bb
+8 -3
View File
@@ -889,15 +889,20 @@ function RuntimeProviders({ children }: { children: ReactNode }) {
);
}
// PortalProvider must remain the innermost global provider here.
// `@gorhom/portal` renders portaled children at the host's location in the
// tree, so any context a portaled sheet might consume (QueryClient, theme,
// auth, settings, …) must wrap PortalProvider — not be wrapped by it.
// Adding a new global provider? Put it above PortalProvider.
function RootProviders({ children }: { children: ReactNode }) {
return (
<PortalProvider>
<QueryProvider>
<SafeAreaProvider>
<KeyboardProvider>
<QueryProvider>{children}</QueryProvider>
<PortalProvider>{children}</PortalProvider>
</KeyboardProvider>
</SafeAreaProvider>
</PortalProvider>
</QueryProvider>
);
}