@trpc/next 10.0.0-proxy-alpha.64 → 10.0.0-proxy-alpha.65
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +4 -1
- package/dist/index.mjs +4 -1
- package/dist/withTRPC.d.ts +1 -0
- package/dist/withTRPC.d.ts.map +1 -1
- package/package.json +8 -8
- package/src/withTRPC.tsx +18 -16
package/dist/index.js
CHANGED
|
@@ -58,7 +58,7 @@ function withTRPC(opts) {
|
|
|
58
58
|
return (AppOrPage)=>{
|
|
59
59
|
const trpc = react.createReactQueryHooks();
|
|
60
60
|
const WithTRPC = (props)=>{
|
|
61
|
-
const [
|
|
61
|
+
const [prepassProps] = React.useState(()=>{
|
|
62
62
|
if (props.trpc) {
|
|
63
63
|
return props.trpc;
|
|
64
64
|
}
|
|
@@ -66,14 +66,17 @@ function withTRPC(opts) {
|
|
|
66
66
|
const queryClient = new reactQuery.QueryClient(config.queryClientConfig);
|
|
67
67
|
const trpcClient = trpc.createClient(config);
|
|
68
68
|
return {
|
|
69
|
+
abortOnUnmount: config.abortOnUnmount,
|
|
69
70
|
queryClient,
|
|
70
71
|
trpcClient,
|
|
71
72
|
ssrState: opts.ssr ? 'mounting' : false,
|
|
72
73
|
ssrContext: null
|
|
73
74
|
};
|
|
74
75
|
});
|
|
76
|
+
const { queryClient , trpcClient , ssrState , ssrContext } = prepassProps;
|
|
75
77
|
const hydratedState = trpc.useDehydratedState(trpcClient, props.pageProps?.trpcState);
|
|
76
78
|
return /*#__PURE__*/ React__default["default"].createElement(trpc.Provider, {
|
|
79
|
+
abortOnUnmount: prepassProps.abortOnUnmount ?? false,
|
|
77
80
|
client: trpcClient,
|
|
78
81
|
queryClient: queryClient,
|
|
79
82
|
ssrState: ssrState,
|
package/dist/index.mjs
CHANGED
|
@@ -49,7 +49,7 @@ function withTRPC(opts) {
|
|
|
49
49
|
return (AppOrPage)=>{
|
|
50
50
|
const trpc = createReactQueryHooks();
|
|
51
51
|
const WithTRPC = (props)=>{
|
|
52
|
-
const [
|
|
52
|
+
const [prepassProps] = useState(()=>{
|
|
53
53
|
if (props.trpc) {
|
|
54
54
|
return props.trpc;
|
|
55
55
|
}
|
|
@@ -57,14 +57,17 @@ function withTRPC(opts) {
|
|
|
57
57
|
const queryClient = new QueryClient(config.queryClientConfig);
|
|
58
58
|
const trpcClient = trpc.createClient(config);
|
|
59
59
|
return {
|
|
60
|
+
abortOnUnmount: config.abortOnUnmount,
|
|
60
61
|
queryClient,
|
|
61
62
|
trpcClient,
|
|
62
63
|
ssrState: opts.ssr ? 'mounting' : false,
|
|
63
64
|
ssrContext: null
|
|
64
65
|
};
|
|
65
66
|
});
|
|
67
|
+
const { queryClient , trpcClient , ssrState , ssrContext } = prepassProps;
|
|
66
68
|
const hydratedState = trpc.useDehydratedState(trpcClient, props.pageProps?.trpcState);
|
|
67
69
|
return /*#__PURE__*/ React.createElement(trpc.Provider, {
|
|
70
|
+
abortOnUnmount: prepassProps.abortOnUnmount ?? false,
|
|
68
71
|
client: trpcClient,
|
|
69
72
|
queryClient: queryClient,
|
|
70
73
|
ssrState: ssrState,
|
package/dist/withTRPC.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ import { NextComponentType, NextPageContext } from 'next/dist/shared/lib/utils';
|
|
|
10
10
|
declare type QueryClientConfig = ConstructorParameters<typeof QueryClient>[0];
|
|
11
11
|
export declare type WithTRPCConfig<TRouter extends AnyRouter> = CreateTRPCClientOptions<TRouter> & {
|
|
12
12
|
queryClientConfig?: QueryClientConfig;
|
|
13
|
+
abortOnUnmount?: boolean;
|
|
13
14
|
};
|
|
14
15
|
interface WithTRPCOptions<TRouter extends AnyRouter> {
|
|
15
16
|
config: (info: {
|
package/dist/withTRPC.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withTRPC.d.ts","sourceRoot":"","sources":["../src/withTRPC.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,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AC,EAAE,eAAe,CAAA;KAAE,KAAK,cAAc,CAAC,OAAO,CAAC,CAAC;CACtE;AAED,MAAM,WAAW,kBAAkB,CAAC,OAAO,SAAS,SAAS,CAC3D,SAAQ,eAAe,CAAC,OAAO,CAAC;IAChC,GAAG,EAAE,IAAI,CAAC;IACV,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE;QACpB,GAAG,EAAE,eAAe,CAAC;QACrB,YAAY,EAAE,eAAe,CAAC,OAAO,CAAC,EAAE,CAAC;KAC1C,KAAK,YAAY,CAAC;CACpB;AACD,MAAM,WAAW,oBAAoB,CAAC,OAAO,SAAS,SAAS,CAC7D,SAAQ,eAAe,CAAC,OAAO,CAAC;IAChC,GAAG,CAAC,EAAE,KAAK,CAAC;CACb;AAED,wBAAgB,QAAQ,CACtB,OAAO,SAAS,SAAS,EACzB,WAAW,SAAS,eAAe,GAAG,eAAe,EACrD,IAAI,EAAE,oBAAoB,CAAC,OAAO,CAAC,GAAG,kBAAkB,CAAC,OAAO,CAAC,eAU9C,kBAAkB,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,KAAG,iBAAiB,CA4KxE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trpc/next",
|
|
3
|
-
"version": "10.0.0-proxy-alpha.
|
|
3
|
+
"version": "10.0.0-proxy-alpha.65",
|
|
4
4
|
"description": "tRPC Next lib",
|
|
5
5
|
"author": "KATT",
|
|
6
6
|
"license": "MIT",
|
|
@@ -36,9 +36,9 @@
|
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
38
|
"@tanstack/react-query": "^4.0.10",
|
|
39
|
-
"@trpc/client": "10.0.0-proxy-alpha.
|
|
40
|
-
"@trpc/react": "10.0.0-proxy-alpha.
|
|
41
|
-
"@trpc/server": "10.0.0-proxy-alpha.
|
|
39
|
+
"@trpc/client": "10.0.0-proxy-alpha.65",
|
|
40
|
+
"@trpc/react": "10.0.0-proxy-alpha.65",
|
|
41
|
+
"@trpc/server": "10.0.0-proxy-alpha.65",
|
|
42
42
|
"next": "*",
|
|
43
43
|
"react": ">=16.8.0",
|
|
44
44
|
"react-dom": ">=16.8.0"
|
|
@@ -48,9 +48,9 @@
|
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@tanstack/react-query": "^4.0.10",
|
|
51
|
-
"@trpc/client": "10.0.0-proxy-alpha.
|
|
52
|
-
"@trpc/react": "10.0.0-proxy-alpha.
|
|
53
|
-
"@trpc/server": "10.0.0-proxy-alpha.
|
|
51
|
+
"@trpc/client": "10.0.0-proxy-alpha.65",
|
|
52
|
+
"@trpc/react": "10.0.0-proxy-alpha.65",
|
|
53
|
+
"@trpc/server": "10.0.0-proxy-alpha.65",
|
|
54
54
|
"@types/express": "^4.17.12",
|
|
55
55
|
"express": "^4.17.1",
|
|
56
56
|
"next": "^12.1.6",
|
|
@@ -61,5 +61,5 @@
|
|
|
61
61
|
"publishConfig": {
|
|
62
62
|
"access": "public"
|
|
63
63
|
},
|
|
64
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "894a354a89794f23009d23fa1449af59aeb9a176"
|
|
65
65
|
}
|
package/src/withTRPC.tsx
CHANGED
|
@@ -54,6 +54,7 @@ function transformQueryOrMutationCacheErrors<
|
|
|
54
54
|
export type WithTRPCConfig<TRouter extends AnyRouter> =
|
|
55
55
|
CreateTRPCClientOptions<TRouter> & {
|
|
56
56
|
queryClientConfig?: QueryClientConfig;
|
|
57
|
+
abortOnUnmount?: boolean;
|
|
57
58
|
};
|
|
58
59
|
|
|
59
60
|
interface WithTRPCOptions<TRouter extends AnyRouter> {
|
|
@@ -94,24 +95,24 @@ export function withTRPC<
|
|
|
94
95
|
trpc?: TRPCPrepassProps;
|
|
95
96
|
},
|
|
96
97
|
) => {
|
|
97
|
-
const [
|
|
98
|
-
()
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
}
|
|
98
|
+
const [prepassProps] = useState(() => {
|
|
99
|
+
if (props.trpc) {
|
|
100
|
+
return props.trpc;
|
|
101
|
+
}
|
|
102
102
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
}
|
|
113
|
-
);
|
|
103
|
+
const config = getClientConfig({});
|
|
104
|
+
const queryClient = new QueryClient(config.queryClientConfig);
|
|
105
|
+
const trpcClient = trpc.createClient(config);
|
|
106
|
+
return {
|
|
107
|
+
abortOnUnmount: config.abortOnUnmount,
|
|
108
|
+
queryClient,
|
|
109
|
+
trpcClient,
|
|
110
|
+
ssrState: opts.ssr ? ('mounting' as const) : (false as const),
|
|
111
|
+
ssrContext: null,
|
|
112
|
+
};
|
|
113
|
+
});
|
|
114
114
|
|
|
115
|
+
const { queryClient, trpcClient, ssrState, ssrContext } = prepassProps;
|
|
115
116
|
const hydratedState = trpc.useDehydratedState(
|
|
116
117
|
trpcClient,
|
|
117
118
|
props.pageProps?.trpcState,
|
|
@@ -119,6 +120,7 @@ export function withTRPC<
|
|
|
119
120
|
|
|
120
121
|
return (
|
|
121
122
|
<trpc.Provider
|
|
123
|
+
abortOnUnmount={(prepassProps as any).abortOnUnmount ?? false}
|
|
122
124
|
client={trpcClient}
|
|
123
125
|
queryClient={queryClient}
|
|
124
126
|
ssrState={ssrState}
|