@octanejs/tanstack-query 0.1.50 → 0.1.52

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.
Files changed (2) hide show
  1. package/package.json +4 -4
  2. package/src/internal.ts +7 -10
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@octanejs/tanstack-query",
3
- "version": "0.1.50",
3
+ "version": "0.1.52",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "engines": {
@@ -40,16 +40,16 @@
40
40
  "@tanstack/query-core": "^5.101.3"
41
41
  },
42
42
  "peerDependencies": {
43
- "octane": "0.1.51"
43
+ "octane": "^0.1.51 || ^0.2.0"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@tanstack/react-query": "^5.101.3",
47
- "@tsrx/react": "^0.2.61",
47
+ "@tsrx/react": "^0.2.63",
48
48
  "esbuild": "^0.28.1",
49
49
  "react": "^19.2.7",
50
50
  "react-dom": "^19.2.7",
51
51
  "vitest": "^4.1.10",
52
- "octane": "0.1.51"
52
+ "octane": "0.2.3"
53
53
  },
54
54
  "scripts": {
55
55
  "test": "vitest run"
package/src/internal.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  // Shared internals for the binding hooks.
2
2
  import { shouldThrowError } from '@tanstack/query-core';
3
- import { subSlot, use, useRef } from 'octane';
3
+ import { subSlot, use, useMemo } from 'octane';
4
4
 
5
5
  export { subSlot };
6
6
 
@@ -78,7 +78,6 @@ type SuspensePromise = PromiseLike<unknown> & {
78
78
  };
79
79
 
80
80
  interface SuspensePromiseCache {
81
- key: unknown;
82
81
  promise: SuspensePromise | undefined;
83
82
  }
84
83
 
@@ -95,8 +94,10 @@ interface SuspensePromiseCache {
95
94
  *
96
95
  * Retain the promise that suspended this query hook and keep reading it after
97
96
  * it settles. That reserves the query hook's call-order position throughout
98
- * the replay episode. A new query key or retry replaces a settled promise;
99
- * re-renders during the same pending fetch reuse the in-flight promise.
97
+ * the replay episode. A key-specific memo lets a held transition restore the
98
+ * committed key's promise when publishing its pending cue. A mutable ref would
99
+ * make that old-key render read the new key's pending promise and show fallback.
100
+ * Re-renders during the same pending fetch reuse the in-flight promise.
100
101
  */
101
102
  export function useSuspensePromise(
102
103
  shouldSuspend: boolean,
@@ -104,12 +105,8 @@ export function useSuspensePromise(
104
105
  createPromise: () => PromiseLike<unknown>,
105
106
  slot: symbol | undefined,
106
107
  ): void {
107
- const cache = useRef<SuspensePromiseCache>({ key: undefined, promise: undefined }, slot).current;
108
- if (
109
- shouldSuspend &&
110
- (cache.promise === undefined || cache.key !== key || cache.promise.status !== 'pending')
111
- ) {
112
- cache.key = key;
108
+ const cache = useMemo<SuspensePromiseCache>(() => ({ promise: undefined }), [key], slot);
109
+ if (shouldSuspend && (cache.promise === undefined || cache.promise.status !== 'pending')) {
113
110
  cache.promise = createPromise() as SuspensePromise;
114
111
  }
115
112
  if (cache.promise !== undefined) use(cache.promise);