minor fixes
This commit is contained in:
+1
-1
@@ -3,7 +3,7 @@
|
|||||||
"description": "SolidJS tRPC",
|
"description": "SolidJS tRPC",
|
||||||
"author": "OrJDev",
|
"author": "OrJDev",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"version": "0.0.9-rc.1",
|
"version": "0.0.10-rc.1",
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"access": "public",
|
"access": "public",
|
||||||
"tag": "next"
|
"tag": "next"
|
||||||
|
|||||||
@@ -178,14 +178,6 @@ export type UseTRPCInfiniteQueryResult<TData, TError> =
|
|||||||
export type UseTRPCMutationResult<TData, TError, TVariables, TContext> =
|
export type UseTRPCMutationResult<TData, TError, TVariables, TContext> =
|
||||||
CreateMutationResult<TData, TError, TVariables, TContext> & TRPCHookResult;
|
CreateMutationResult<TData, TError, TVariables, TContext> & 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
|
* Create strongly typed react hooks
|
||||||
* @internal
|
* @internal
|
||||||
@@ -398,7 +390,7 @@ export function createHooksInternal<
|
|||||||
|
|
||||||
const shouldAbortOnUnmount = () =>
|
const shouldAbortOnUnmount = () =>
|
||||||
opts?.trpc?.abortOnUnmount ?? ctx?.abortOnUnmount ?? false;
|
opts?.trpc?.abortOnUnmount ?? ctx?.abortOnUnmount ?? false;
|
||||||
const hook = __useQuery(
|
return __useQuery(
|
||||||
() => getArrayQueryKey(pathAndInput()),
|
() => getArrayQueryKey(pathAndInput()),
|
||||||
(queryFunctionContext) => {
|
(queryFunctionContext) => {
|
||||||
const actualOpts = () => ({
|
const actualOpts = () => ({
|
||||||
@@ -414,12 +406,11 @@ export function createHooksInternal<
|
|||||||
...getClientArgs(pathAndInput(), actualOpts())
|
...getClientArgs(pathAndInput(), actualOpts())
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
opts as any
|
{
|
||||||
|
context: SolidQueryContext,
|
||||||
|
...opts,
|
||||||
|
} as any
|
||||||
) as UseTRPCQueryResult<TData, TError>;
|
) as UseTRPCQueryResult<TData, TError>;
|
||||||
hook.trpc = useHookResult({
|
|
||||||
path: pathAndInput()[0],
|
|
||||||
});
|
|
||||||
return hook;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function useMutation<
|
function useMutation<
|
||||||
@@ -442,7 +433,7 @@ export function createHooksInternal<
|
|||||||
const ctx = useContext();
|
const ctx = useContext();
|
||||||
const queryClient = useQueryClient({ context: SolidQueryContext });
|
const queryClient = useQueryClient({ context: SolidQueryContext });
|
||||||
|
|
||||||
const hook = __useMutation(
|
return __useMutation(
|
||||||
(input) => {
|
(input) => {
|
||||||
const actualPath = Array.isArray(path) ? path[0] : path;
|
const actualPath = Array.isArray(path) ? path[0] : path;
|
||||||
|
|
||||||
@@ -464,12 +455,6 @@ export function createHooksInternal<
|
|||||||
TMutationValues[TPath]["input"],
|
TMutationValues[TPath]["input"],
|
||||||
TContext
|
TContext
|
||||||
>;
|
>;
|
||||||
|
|
||||||
hook.trpc = useHookResult({
|
|
||||||
path: Array.isArray(path) ? path[0] : path,
|
|
||||||
});
|
|
||||||
|
|
||||||
return hook;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* istanbul ignore next */
|
/* istanbul ignore next */
|
||||||
@@ -561,7 +546,7 @@ export function createHooksInternal<
|
|||||||
const shouldAbortOnUnmount =
|
const shouldAbortOnUnmount =
|
||||||
opts?.trpc?.abortOnUnmount ?? ctx?.abortOnUnmount ?? false;
|
opts?.trpc?.abortOnUnmount ?? ctx?.abortOnUnmount ?? false;
|
||||||
|
|
||||||
const hook = __useInfiniteQuery(
|
return __useInfiniteQuery(
|
||||||
() => getArrayQueryKey(pathAndInput()),
|
() => getArrayQueryKey(pathAndInput()),
|
||||||
(queryFunctionContext) => {
|
(queryFunctionContext) => {
|
||||||
const actualOpts = () => ({
|
const actualOpts = () => ({
|
||||||
@@ -585,11 +570,6 @@ export function createHooksInternal<
|
|||||||
},
|
},
|
||||||
{ context: SolidQueryContext, ...ssrOpts } as any
|
{ context: SolidQueryContext, ...ssrOpts } as any
|
||||||
) as UseTRPCInfiniteQueryResult<TQueryValues[TPath]["output"], TError>;
|
) as UseTRPCInfiniteQueryResult<TQueryValues[TPath]["output"], TError>;
|
||||||
|
|
||||||
hook.trpc = useHookResult({
|
|
||||||
path: pathAndInput()[0],
|
|
||||||
});
|
|
||||||
return hook;
|
|
||||||
}
|
}
|
||||||
const useDehydratedState: UseDehydratedState<TRouter> = (
|
const useDehydratedState: UseDehydratedState<TRouter> = (
|
||||||
client,
|
client,
|
||||||
|
|||||||
Reference in New Issue
Block a user