mirror of
https://github.com/supabase/supabase.git
synced 2026-07-02 17:44:25 +08:00
* feat(blog): Add React Query post. * feat(examples): Add React Query example. * Apply suggestions from code review Thank you 💚 Co-authored-by: Philipp Steinrötter <philipp@steinroetter.com> * chore: update og image. --------- Co-authored-by: Philipp Steinrötter <philipp@steinroetter.com>
27 lines
639 B
TypeScript
27 lines
639 B
TypeScript
'use client'
|
|
|
|
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
|
import { useState } from 'react'
|
|
|
|
export const ReactQueryClientProvider = ({
|
|
children,
|
|
}: {
|
|
children: React.ReactNode
|
|
}) => {
|
|
const [queryClient] = useState(
|
|
() =>
|
|
new QueryClient({
|
|
defaultOptions: {
|
|
queries: {
|
|
// With SSR, we usually want to set some default staleTime
|
|
// above 0 to avoid refetching immediately on the client
|
|
staleTime: 60 * 1000,
|
|
},
|
|
},
|
|
})
|
|
)
|
|
return (
|
|
<QueryClientProvider client={queryClient}>{children}</QueryClientProvider>
|
|
)
|
|
}
|