diff --git a/package.json b/package.json index 18c08ba..3cfdce2 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "description": "SolidJS tRPC", "author": "OrJDev", "license": "MIT", - "version": "0.0.9-rc.1", + "version": "0.0.10-rc.1", "publishConfig": { "access": "public", "tag": "next" diff --git a/src/shared/hooks/createHooksInternal.tsx b/src/shared/hooks/createHooksInternal.tsx index 29cc0d1..1599a86 100644 --- a/src/shared/hooks/createHooksInternal.tsx +++ b/src/shared/hooks/createHooksInternal.tsx @@ -178,14 +178,6 @@ export type UseTRPCInfiniteQueryResult = export type UseTRPCMutationResult = CreateMutationResult & TRPCHookResult; -/** - * Makes a stable reference of the `trpc` prop - */ -function useHookResult(value: TRPCHookResult["trpc"]): TRPCHookResult["trpc"] { - const ref = { current: value }; - ref.current.path = value.path; - return ref.current; -} /** * Create strongly typed react hooks * @internal @@ -398,7 +390,7 @@ export function createHooksInternal< const shouldAbortOnUnmount = () => opts?.trpc?.abortOnUnmount ?? ctx?.abortOnUnmount ?? false; - const hook = __useQuery( + return __useQuery( () => getArrayQueryKey(pathAndInput()), (queryFunctionContext) => { const actualOpts = () => ({ @@ -414,12 +406,11 @@ export function createHooksInternal< ...getClientArgs(pathAndInput(), actualOpts()) ); }, - opts as any + { + context: SolidQueryContext, + ...opts, + } as any ) as UseTRPCQueryResult; - hook.trpc = useHookResult({ - path: pathAndInput()[0], - }); - return hook; } function useMutation< @@ -442,7 +433,7 @@ export function createHooksInternal< const ctx = useContext(); const queryClient = useQueryClient({ context: SolidQueryContext }); - const hook = __useMutation( + return __useMutation( (input) => { const actualPath = Array.isArray(path) ? path[0] : path; @@ -464,12 +455,6 @@ export function createHooksInternal< TMutationValues[TPath]["input"], TContext >; - - hook.trpc = useHookResult({ - path: Array.isArray(path) ? path[0] : path, - }); - - return hook; } /* istanbul ignore next */ @@ -561,7 +546,7 @@ export function createHooksInternal< const shouldAbortOnUnmount = opts?.trpc?.abortOnUnmount ?? ctx?.abortOnUnmount ?? false; - const hook = __useInfiniteQuery( + return __useInfiniteQuery( () => getArrayQueryKey(pathAndInput()), (queryFunctionContext) => { const actualOpts = () => ({ @@ -585,11 +570,6 @@ export function createHooksInternal< }, { context: SolidQueryContext, ...ssrOpts } as any ) as UseTRPCInfiniteQueryResult; - - hook.trpc = useHookResult({ - path: pathAndInput()[0], - }); - return hook; } const useDehydratedState: UseDehydratedState = ( client,