@octanejs/tanstack-router 0.1.27 → 0.1.29
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/package.json +3 -3
- package/src/utils.ts +21 -9
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@octanejs/tanstack-router",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.29",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"isbot": "^5.1.22"
|
|
59
59
|
},
|
|
60
60
|
"peerDependencies": {
|
|
61
|
-
"octane": "0.1.
|
|
61
|
+
"octane": "0.1.30"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
64
|
"@tanstack/react-router": "1.170.18",
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"react": "^19.2.7",
|
|
68
68
|
"react-dom": "^19.2.7",
|
|
69
69
|
"vitest": "^4.1.10",
|
|
70
|
-
"octane": "0.1.
|
|
70
|
+
"octane": "0.1.30"
|
|
71
71
|
},
|
|
72
72
|
"scripts": {
|
|
73
73
|
"test": "vitest run"
|
package/src/utils.ts
CHANGED
|
@@ -1,18 +1,30 @@
|
|
|
1
1
|
// Small hook utilities ported from react-router's utils.tsx. Plain-`.ts` hooks
|
|
2
2
|
// forward the caller's compiler-injected slot (see internal.ts).
|
|
3
|
-
import {
|
|
3
|
+
import { type LinkedStatePrevious, useLinkedState } from 'octane';
|
|
4
4
|
import { splitSlot, subSlot } from './internal';
|
|
5
5
|
|
|
6
|
+
function previousCommittedValue<Value>(
|
|
7
|
+
_current: Value,
|
|
8
|
+
previous: LinkedStatePrevious<Value, Value | null> | undefined,
|
|
9
|
+
): Value | null {
|
|
10
|
+
return previous === undefined ? null : previous.source;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const PREVIOUS_VALUE_OPTIONS = {
|
|
14
|
+
sourceEqual: <Value>(previous: Value, next: Value) => previous === next,
|
|
15
|
+
};
|
|
16
|
+
|
|
6
17
|
// Returns the value from the previous render (null on first render). Ported from
|
|
7
|
-
// react-router's usePrevious —
|
|
8
|
-
//
|
|
18
|
+
// react-router's usePrevious — linked state advances only when a changed value commits,
|
|
19
|
+
// keeping abandoned Suspense attempts out of the previous-distinct history.
|
|
9
20
|
export function usePrevious(...args: any[]): any {
|
|
10
21
|
const [user, slot] = splitSlot(args);
|
|
11
22
|
const value = user[0];
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
23
|
+
const [previous] = useLinkedState(
|
|
24
|
+
value,
|
|
25
|
+
previousCommittedValue,
|
|
26
|
+
PREVIOUS_VALUE_OPTIONS,
|
|
27
|
+
subSlot(slot, 'prev'),
|
|
28
|
+
);
|
|
29
|
+
return previous;
|
|
18
30
|
}
|