This page looks best with JavaScript enabled
TypeScriptでライブラリをラッパーして型を閉じ込める
結論
TanStack Queryの例です
1
2
3
4
5
6
7
8
9
10
|
import {QueryClient as QueryClientImpl, QueryClientProvider as ReactQueryQueryClientProvider} from "@tanstack/react-query"
import {ReactNode} from "react"
export const createClient = (): QueryClient => new QueryClientImpl()
export const QueryClientProvider = ({client, children}: {client: QueryClient, children: ReactNode}) => {
return <ReactQueryQueryClientProvider client={client as QueryClientImpl}>{children}</ReactQueryQueryClientProvider>
}
export type QueryClient = {}
|
WRITTEN BY
ippachi
Software Developer