@trpc/react-query 10.20.0 → 10.21.1-alpha.0
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/{createHooksInternal-0b1b3a6c.js → createHooksInternal-54133db9.js} +5 -3
- package/dist/{createHooksInternal-281fcd80.js → createHooksInternal-e8871abb.js} +5 -3
- package/dist/{createHooksInternal-31c91d2f.mjs → createHooksInternal-f30efef6.mjs} +5 -3
- package/dist/index.js +1 -1
- package/dist/index.mjs +2 -2
- package/dist/shared/hooks/createHooksInternal.d.ts.map +1 -1
- package/dist/shared/index.js +1 -1
- package/dist/shared/index.mjs +1 -1
- package/package.json +6 -6
- package/src/shared/hooks/createHooksInternal.tsx +13 -4
|
@@ -361,6 +361,8 @@ function createRootHooks(config) {
|
|
|
361
361
|
const enabled = opts?.enabled ?? true;
|
|
362
362
|
const queryKey = hashQueryKey(pathAndInput);
|
|
363
363
|
const { client } = useContext();
|
|
364
|
+
const optsRef = useRef(opts);
|
|
365
|
+
optsRef.current = opts;
|
|
364
366
|
return useEffect(() => {
|
|
365
367
|
if (!enabled) {
|
|
366
368
|
return;
|
|
@@ -370,18 +372,18 @@ function createRootHooks(config) {
|
|
|
370
372
|
const subscription = client.subscription(path, (input ?? undefined), {
|
|
371
373
|
onStarted: () => {
|
|
372
374
|
if (!isStopped) {
|
|
373
|
-
|
|
375
|
+
optsRef.current.onStarted?.();
|
|
374
376
|
}
|
|
375
377
|
},
|
|
376
378
|
onData: (data) => {
|
|
377
379
|
if (!isStopped) {
|
|
378
380
|
// FIXME this shouldn't be needed as both should be `unknown` in next major
|
|
379
|
-
|
|
381
|
+
optsRef.current.onData(data);
|
|
380
382
|
}
|
|
381
383
|
},
|
|
382
384
|
onError: (err) => {
|
|
383
385
|
if (!isStopped) {
|
|
384
|
-
|
|
386
|
+
optsRef.current.onError?.(err);
|
|
385
387
|
}
|
|
386
388
|
},
|
|
387
389
|
});
|
|
@@ -424,6 +424,8 @@ function getClientArgs(pathAndInput, opts) {
|
|
|
424
424
|
const enabled = opts?.enabled ?? true;
|
|
425
425
|
const queryKey = reactQuery.hashQueryKey(pathAndInput);
|
|
426
426
|
const { client } = useContext();
|
|
427
|
+
const optsRef = React.useRef(opts);
|
|
428
|
+
optsRef.current = opts;
|
|
427
429
|
return React.useEffect(()=>{
|
|
428
430
|
if (!enabled) {
|
|
429
431
|
return;
|
|
@@ -433,18 +435,18 @@ function getClientArgs(pathAndInput, opts) {
|
|
|
433
435
|
const subscription = client.subscription(path, input ?? undefined, {
|
|
434
436
|
onStarted: ()=>{
|
|
435
437
|
if (!isStopped) {
|
|
436
|
-
|
|
438
|
+
optsRef.current.onStarted?.();
|
|
437
439
|
}
|
|
438
440
|
},
|
|
439
441
|
onData: (data)=>{
|
|
440
442
|
if (!isStopped) {
|
|
441
443
|
// FIXME this shouldn't be needed as both should be `unknown` in next major
|
|
442
|
-
|
|
444
|
+
optsRef.current.onData(data);
|
|
443
445
|
}
|
|
444
446
|
},
|
|
445
447
|
onError: (err)=>{
|
|
446
448
|
if (!isStopped) {
|
|
447
|
-
|
|
449
|
+
optsRef.current.onError?.(err);
|
|
448
450
|
}
|
|
449
451
|
}
|
|
450
452
|
});
|
|
@@ -418,6 +418,8 @@ function getClientArgs(pathAndInput, opts) {
|
|
|
418
418
|
const enabled = opts?.enabled ?? true;
|
|
419
419
|
const queryKey = hashQueryKey(pathAndInput);
|
|
420
420
|
const { client } = useContext();
|
|
421
|
+
const optsRef = useRef(opts);
|
|
422
|
+
optsRef.current = opts;
|
|
421
423
|
return useEffect(()=>{
|
|
422
424
|
if (!enabled) {
|
|
423
425
|
return;
|
|
@@ -427,18 +429,18 @@ function getClientArgs(pathAndInput, opts) {
|
|
|
427
429
|
const subscription = client.subscription(path, input ?? undefined, {
|
|
428
430
|
onStarted: ()=>{
|
|
429
431
|
if (!isStopped) {
|
|
430
|
-
|
|
432
|
+
optsRef.current.onStarted?.();
|
|
431
433
|
}
|
|
432
434
|
},
|
|
433
435
|
onData: (data)=>{
|
|
434
436
|
if (!isStopped) {
|
|
435
437
|
// FIXME this shouldn't be needed as both should be `unknown` in next major
|
|
436
|
-
|
|
438
|
+
optsRef.current.onData(data);
|
|
437
439
|
}
|
|
438
440
|
},
|
|
439
441
|
onError: (err)=>{
|
|
440
442
|
if (!isStopped) {
|
|
441
|
-
|
|
443
|
+
optsRef.current.onError?.(err);
|
|
442
444
|
}
|
|
443
445
|
}
|
|
444
446
|
});
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var client = require('@trpc/client');
|
|
6
|
-
var createHooksInternal = require('./createHooksInternal-
|
|
6
|
+
var createHooksInternal = require('./createHooksInternal-e8871abb.js');
|
|
7
7
|
var shared = require('@trpc/server/shared');
|
|
8
8
|
var React = require('react');
|
|
9
9
|
require('@tanstack/react-query');
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export * from '@trpc/client';
|
|
2
|
-
import { c as createHooksInternal, a as createReactQueryUtilsProxy, b as createReactProxyDecoration } from './createHooksInternal-
|
|
3
|
-
export { g as getQueryKey } from './createHooksInternal-
|
|
2
|
+
import { c as createHooksInternal, a as createReactQueryUtilsProxy, b as createReactProxyDecoration } from './createHooksInternal-f30efef6.mjs';
|
|
3
|
+
export { g as getQueryKey } from './createHooksInternal-f30efef6.mjs';
|
|
4
4
|
import { createFlatProxy } from '@trpc/server/shared';
|
|
5
5
|
import { useMemo } from 'react';
|
|
6
6
|
import '@tanstack/react-query';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createHooksInternal.d.ts","sourceRoot":"","sources":["../../../src/shared/hooks/createHooksInternal.tsx"],"names":[],"mappings":"AAWA,OAAO,EAAE,mBAAmB,EAAoB,MAAM,cAAc,CAAC;AACrE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"createHooksInternal.d.ts","sourceRoot":"","sources":["../../../src/shared/hooks/createHooksInternal.tsx"],"names":[],"mappings":"AAWA,OAAO,EAAE,mBAAmB,EAAoB,MAAM,cAAc,CAAC;AACrE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AASrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAI3D,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAE5D,OAAO,EAAE,sBAAsB,EAAuB,MAAM,UAAU,CAAC;AACvE,OAAO,EACL,YAAY,EACZ,YAAY,EAEZ,kBAAkB,EAClB,2BAA2B,EAC3B,0BAA0B,EAC1B,sBAAsB,EACtB,qBAAqB,EACrB,mBAAmB,EACnB,kBAAkB,EAClB,0BAA0B,EAC3B,MAAM,SAAS,CAAC;AAEjB;;GAEG;AACH,wBAAgB,eAAe,CAC7B,OAAO,SAAS,SAAS,EACzB,WAAW,GAAG,OAAO,EACrB,MAAM,CAAC,EAAE,sBAAsB,CAAC,OAAO,CAAC;;;;6BAmOxB,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,CAAC;;wBAwD1C,MAAM,GAAG,CAAC,MAAM,CAAC;oCAoCT;QAEZ,IAAI,EAAE,MAAM;QACZ,GAAG,IAAI,EAAE,OAAO,EAAE;KACnB;;qCA+Ca;QAEZ,IAAI,EAAE,MAAM;QACZ,KAAK,EAAE,OAAO,GAAG,EAAE,OAAO,CAAC;KAC5B;EAqHJ"}
|
package/dist/shared/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var createHooksInternal = require('../createHooksInternal-
|
|
5
|
+
var createHooksInternal = require('../createHooksInternal-e8871abb.js');
|
|
6
6
|
var queryClient = require('../queryClient-358a9a75.js');
|
|
7
7
|
require('@trpc/server/shared');
|
|
8
8
|
require('../getArrayQueryKey-4bdb5cc2.js');
|
package/dist/shared/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { T as TRPCContext, h as contextProps, c as createHooksInternal, b as createReactProxyDecoration, a as createReactQueryUtilsProxy, f as createRootHooks, e as createUseQueriesProxy, d as getClientArgs } from '../createHooksInternal-
|
|
1
|
+
export { T as TRPCContext, h as contextProps, c as createHooksInternal, b as createReactProxyDecoration, a as createReactQueryUtilsProxy, f as createRootHooks, e as createUseQueriesProxy, d as getClientArgs } from '../createHooksInternal-f30efef6.mjs';
|
|
2
2
|
export { g as getQueryClient } from '../queryClient-4d766c0c.mjs';
|
|
3
3
|
import '@trpc/server/shared';
|
|
4
4
|
import '../getArrayQueryKey-86134f8b.mjs';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trpc/react-query",
|
|
3
|
-
"version": "10.
|
|
3
|
+
"version": "10.21.1-alpha.0",
|
|
4
4
|
"description": "tRPC React lib",
|
|
5
5
|
"author": "KATT",
|
|
6
6
|
"license": "MIT",
|
|
@@ -63,15 +63,15 @@
|
|
|
63
63
|
},
|
|
64
64
|
"peerDependencies": {
|
|
65
65
|
"@tanstack/react-query": "^4.18.0",
|
|
66
|
-
"@trpc/client": "10.
|
|
67
|
-
"@trpc/server": "10.
|
|
66
|
+
"@trpc/client": "10.21.0",
|
|
67
|
+
"@trpc/server": "10.21.0",
|
|
68
68
|
"react": ">=16.8.0",
|
|
69
69
|
"react-dom": ">=16.8.0"
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
72
72
|
"@tanstack/react-query": "^4.18.0",
|
|
73
|
-
"@trpc/client": "10.
|
|
74
|
-
"@trpc/server": "10.
|
|
73
|
+
"@trpc/client": "^10.21.1-alpha.0",
|
|
74
|
+
"@trpc/server": "^10.21.1-alpha.0",
|
|
75
75
|
"@types/express": "^4.17.12",
|
|
76
76
|
"@types/node": "^18.7.20",
|
|
77
77
|
"@types/react": "^18.0.9",
|
|
@@ -87,5 +87,5 @@
|
|
|
87
87
|
"publishConfig": {
|
|
88
88
|
"access": "public"
|
|
89
89
|
},
|
|
90
|
-
"gitHead": "
|
|
90
|
+
"gitHead": "04a16ddc5d93f4b26e720bd9243f6cf3e3e6cc5a"
|
|
91
91
|
}
|
|
@@ -12,7 +12,13 @@ import {
|
|
|
12
12
|
import { TRPCClientErrorLike, createTRPCClient } from '@trpc/client';
|
|
13
13
|
import type { AnyRouter } from '@trpc/server';
|
|
14
14
|
import { Observable } from '@trpc/server/observable';
|
|
15
|
-
import React, {
|
|
15
|
+
import React, {
|
|
16
|
+
useCallback,
|
|
17
|
+
useEffect,
|
|
18
|
+
useMemo,
|
|
19
|
+
useRef,
|
|
20
|
+
useState,
|
|
21
|
+
} from 'react';
|
|
16
22
|
import { SSRState, TRPCContext } from '../../internals/context';
|
|
17
23
|
import { TRPCContextState } from '../../internals/context';
|
|
18
24
|
import { QueryType, getArrayQueryKey } from '../../internals/getArrayQueryKey';
|
|
@@ -371,6 +377,9 @@ export function createRootHooks<
|
|
|
371
377
|
const queryKey = hashQueryKey(pathAndInput);
|
|
372
378
|
const { client } = useContext();
|
|
373
379
|
|
|
380
|
+
const optsRef = useRef<typeof opts>(opts);
|
|
381
|
+
optsRef.current = opts;
|
|
382
|
+
|
|
374
383
|
return useEffect(() => {
|
|
375
384
|
if (!enabled) {
|
|
376
385
|
return;
|
|
@@ -383,18 +392,18 @@ export function createRootHooks<
|
|
|
383
392
|
{
|
|
384
393
|
onStarted: () => {
|
|
385
394
|
if (!isStopped) {
|
|
386
|
-
|
|
395
|
+
optsRef.current.onStarted?.();
|
|
387
396
|
}
|
|
388
397
|
},
|
|
389
398
|
onData: (data) => {
|
|
390
399
|
if (!isStopped) {
|
|
391
400
|
// FIXME this shouldn't be needed as both should be `unknown` in next major
|
|
392
|
-
|
|
401
|
+
optsRef.current.onData(data as any);
|
|
393
402
|
}
|
|
394
403
|
},
|
|
395
404
|
onError: (err) => {
|
|
396
405
|
if (!isStopped) {
|
|
397
|
-
|
|
406
|
+
optsRef.current.onError?.(err);
|
|
398
407
|
}
|
|
399
408
|
},
|
|
400
409
|
},
|