( queryClient?: Accessor<QueryClient | undefined>, )
| 45 | * @returns An accessor that returns the resolved client. It throws if neither client is available. |
| 46 | */ |
| 47 | export const useQueryClientResolver = ( |
| 48 | queryClient?: Accessor<QueryClient | undefined>, |
| 49 | ): Accessor<QueryClient> => { |
| 50 | const contextClient = useContext(QueryClientContext) |
| 51 | |
| 52 | return () => { |
| 53 | const resolvedClient = queryClient?.() |
| 54 | if (resolvedClient) { |
| 55 | return resolvedClient |
| 56 | } |
| 57 | |
| 58 | if (!contextClient) { |
| 59 | throw new Error(queryClientContextError) |
| 60 | } |
| 61 | |
| 62 | return contextClient() |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | /** |
| 67 | * The props accepted by `QueryClientProvider`. |
no outgoing calls