API/<QubeeFetchProvider>
<QubeeFetchProvider>
componentsrc/components/qubee-fetch-provider.tsx1 parameter
Set what performs the requests of every fetching hook below it — useQubeeQuery, and
useQubeeSWR from the SWR entry.
Without a provider the hooks use the global fetch. A hook given its own fetcher uses that
one; the nearest provider wins over the ones above it. In a Next.js server layout, render it
inside a Client Component of your own: a function cannot cross the server–client boundary as
a prop.
Import
Section titled “Import”import { QubeeFetchProvider } from '@qubeejs/react';Signature
Section titled “Signature”function QubeeFetchProvider(props: QubeeFetchProviderProps): ReactElementParameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
props |
QubeeFetchProviderProps |
The fetcher, and the subtree |
Returns
Section titled “Returns”The subtree, with the fetcher in context
Example
Section titled “Example”const authFetch: QubeeFetcher = (uri, init) => fetch(uri, { ...init, headers: { ...init.headers, Authorization: `Bearer ${token()}` } });
<QubeeFetchProvider fetcher={authFetch}> <App /></QubeeFetchProvider>