mirror of
https://github.com/FranP-code/create-better-t-stack.git
synced 2025-10-12 23:52:15 +00:00
fix orpc templates (#302)
This commit is contained in:
@@ -5,10 +5,6 @@ import { QueryCache, QueryClient } from "@tanstack/react-query";
|
||||
import { toast } from "sonner";
|
||||
import type { appRouter } from "../../../server/src/routers/index";
|
||||
import type { RouterClient } from "@orpc/server";
|
||||
import { createContext, use } from 'react'
|
||||
import type { RouterUtils } from '@orpc/tanstack-query'
|
||||
|
||||
type ORPCReactUtils = RouterUtils<RouterClient<typeof appRouter>>
|
||||
|
||||
export const queryClient = new QueryClient({
|
||||
queryCache: new QueryCache({
|
||||
@@ -44,14 +40,3 @@ export const link = new RPCLink({
|
||||
export const client: RouterClient<typeof appRouter> = createORPCClient(link)
|
||||
|
||||
export const orpc = createTanstackQueryUtils(client)
|
||||
|
||||
|
||||
export const ORPCContext = createContext<ORPCReactUtils | undefined>(undefined)
|
||||
|
||||
export function useORPC(): ORPCReactUtils {
|
||||
const orpc = use(ORPCContext)
|
||||
if (!orpc) {
|
||||
throw new Error('ORPCContext is not set up properly')
|
||||
}
|
||||
return orpc
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user