@tanstack/react-router 0.0.1-beta.72 → 0.0.1-beta.75
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/build/cjs/index.js +12 -8
- package/build/cjs/index.js.map +1 -1
- package/build/esm/index.js +12 -8
- package/build/esm/index.js.map +1 -1
- package/build/stats-html.html +1 -1
- package/build/stats-react.json +57 -57
- package/build/types/index.d.ts +1 -1
- package/build/umd/index.development.js +43 -38
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +2 -2
- package/build/umd/index.production.js.map +1 -1
- package/package.json +2 -2
- package/src/index.tsx +10 -13
package/build/stats-react.json
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
"name": "index.production.js",
|
|
8
8
|
"children": [
|
|
9
9
|
{
|
|
10
|
-
"uid": "
|
|
10
|
+
"uid": "37ac-109",
|
|
11
11
|
"name": "\u0000rollupPluginBabelHelpers.js"
|
|
12
12
|
},
|
|
13
13
|
{
|
|
@@ -15,11 +15,11 @@
|
|
|
15
15
|
"children": [
|
|
16
16
|
{
|
|
17
17
|
"name": "tiny-invariant@1.3.1/node_modules/tiny-invariant/dist/esm/tiny-invariant.js",
|
|
18
|
-
"uid": "
|
|
18
|
+
"uid": "37ac-111"
|
|
19
19
|
},
|
|
20
20
|
{
|
|
21
21
|
"name": "tiny-warning@1.0.3/node_modules/tiny-warning/dist/tiny-warning.esm.js",
|
|
22
|
-
"uid": "
|
|
22
|
+
"uid": "37ac-113"
|
|
23
23
|
}
|
|
24
24
|
]
|
|
25
25
|
},
|
|
@@ -28,19 +28,19 @@
|
|
|
28
28
|
"children": [
|
|
29
29
|
{
|
|
30
30
|
"name": "store/build/esm/index.js",
|
|
31
|
-
"uid": "
|
|
31
|
+
"uid": "37ac-115"
|
|
32
32
|
},
|
|
33
33
|
{
|
|
34
34
|
"name": "router/build/esm/index.js",
|
|
35
|
-
"uid": "
|
|
35
|
+
"uid": "37ac-117"
|
|
36
36
|
},
|
|
37
37
|
{
|
|
38
38
|
"name": "react-store/build/esm/index.js",
|
|
39
|
-
"uid": "
|
|
39
|
+
"uid": "37ac-119"
|
|
40
40
|
},
|
|
41
41
|
{
|
|
42
42
|
"name": "react-router/src/index.tsx",
|
|
43
|
-
"uid": "
|
|
43
|
+
"uid": "37ac-121"
|
|
44
44
|
}
|
|
45
45
|
]
|
|
46
46
|
}
|
|
@@ -50,176 +50,176 @@
|
|
|
50
50
|
"isRoot": true
|
|
51
51
|
},
|
|
52
52
|
"nodeParts": {
|
|
53
|
-
"
|
|
53
|
+
"37ac-109": {
|
|
54
54
|
"renderedLength": 429,
|
|
55
55
|
"gzipLength": 238,
|
|
56
56
|
"brotliLength": 0,
|
|
57
|
-
"mainUid": "
|
|
57
|
+
"mainUid": "37ac-108"
|
|
58
58
|
},
|
|
59
|
-
"
|
|
59
|
+
"37ac-111": {
|
|
60
60
|
"renderedLength": 181,
|
|
61
61
|
"gzipLength": 129,
|
|
62
62
|
"brotliLength": 0,
|
|
63
|
-
"mainUid": "
|
|
63
|
+
"mainUid": "37ac-110"
|
|
64
64
|
},
|
|
65
|
-
"
|
|
65
|
+
"37ac-113": {
|
|
66
66
|
"renderedLength": 44,
|
|
67
67
|
"gzipLength": 62,
|
|
68
68
|
"brotliLength": 0,
|
|
69
|
-
"mainUid": "
|
|
69
|
+
"mainUid": "37ac-112"
|
|
70
70
|
},
|
|
71
|
-
"
|
|
71
|
+
"37ac-115": {
|
|
72
72
|
"renderedLength": 1288,
|
|
73
73
|
"gzipLength": 497,
|
|
74
74
|
"brotliLength": 0,
|
|
75
|
-
"mainUid": "
|
|
75
|
+
"mainUid": "37ac-114"
|
|
76
76
|
},
|
|
77
|
-
"
|
|
78
|
-
"renderedLength":
|
|
79
|
-
"gzipLength":
|
|
77
|
+
"37ac-117": {
|
|
78
|
+
"renderedLength": 46913,
|
|
79
|
+
"gzipLength": 11093,
|
|
80
80
|
"brotliLength": 0,
|
|
81
|
-
"mainUid": "
|
|
81
|
+
"mainUid": "37ac-116"
|
|
82
82
|
},
|
|
83
|
-
"
|
|
83
|
+
"37ac-119": {
|
|
84
84
|
"renderedLength": 1571,
|
|
85
85
|
"gzipLength": 594,
|
|
86
86
|
"brotliLength": 0,
|
|
87
|
-
"mainUid": "
|
|
87
|
+
"mainUid": "37ac-118"
|
|
88
88
|
},
|
|
89
|
-
"
|
|
90
|
-
"renderedLength":
|
|
91
|
-
"gzipLength":
|
|
89
|
+
"37ac-121": {
|
|
90
|
+
"renderedLength": 12591,
|
|
91
|
+
"gzipLength": 3262,
|
|
92
92
|
"brotliLength": 0,
|
|
93
|
-
"mainUid": "
|
|
93
|
+
"mainUid": "37ac-120"
|
|
94
94
|
}
|
|
95
95
|
},
|
|
96
96
|
"nodeMetas": {
|
|
97
|
-
"
|
|
97
|
+
"37ac-108": {
|
|
98
98
|
"id": "\u0000rollupPluginBabelHelpers.js",
|
|
99
99
|
"moduleParts": {
|
|
100
|
-
"index.production.js": "
|
|
100
|
+
"index.production.js": "37ac-109"
|
|
101
101
|
},
|
|
102
102
|
"imported": [],
|
|
103
103
|
"importedBy": [
|
|
104
104
|
{
|
|
105
|
-
"uid": "
|
|
105
|
+
"uid": "37ac-120"
|
|
106
106
|
}
|
|
107
107
|
]
|
|
108
108
|
},
|
|
109
|
-
"
|
|
109
|
+
"37ac-110": {
|
|
110
110
|
"id": "/node_modules/.pnpm/tiny-invariant@1.3.1/node_modules/tiny-invariant/dist/esm/tiny-invariant.js",
|
|
111
111
|
"moduleParts": {
|
|
112
|
-
"index.production.js": "
|
|
112
|
+
"index.production.js": "37ac-111"
|
|
113
113
|
},
|
|
114
114
|
"imported": [],
|
|
115
115
|
"importedBy": [
|
|
116
116
|
{
|
|
117
|
-
"uid": "
|
|
117
|
+
"uid": "37ac-116"
|
|
118
118
|
}
|
|
119
119
|
]
|
|
120
120
|
},
|
|
121
|
-
"
|
|
121
|
+
"37ac-112": {
|
|
122
122
|
"id": "/node_modules/.pnpm/tiny-warning@1.0.3/node_modules/tiny-warning/dist/tiny-warning.esm.js",
|
|
123
123
|
"moduleParts": {
|
|
124
|
-
"index.production.js": "
|
|
124
|
+
"index.production.js": "37ac-113"
|
|
125
125
|
},
|
|
126
126
|
"imported": [],
|
|
127
127
|
"importedBy": [
|
|
128
128
|
{
|
|
129
|
-
"uid": "
|
|
129
|
+
"uid": "37ac-116"
|
|
130
130
|
}
|
|
131
131
|
]
|
|
132
132
|
},
|
|
133
|
-
"
|
|
133
|
+
"37ac-114": {
|
|
134
134
|
"id": "/packages/store/build/esm/index.js",
|
|
135
135
|
"moduleParts": {
|
|
136
|
-
"index.production.js": "
|
|
136
|
+
"index.production.js": "37ac-115"
|
|
137
137
|
},
|
|
138
138
|
"imported": [],
|
|
139
139
|
"importedBy": [
|
|
140
140
|
{
|
|
141
|
-
"uid": "
|
|
141
|
+
"uid": "37ac-116"
|
|
142
142
|
}
|
|
143
143
|
]
|
|
144
144
|
},
|
|
145
|
-
"
|
|
145
|
+
"37ac-116": {
|
|
146
146
|
"id": "/packages/router/build/esm/index.js",
|
|
147
147
|
"moduleParts": {
|
|
148
|
-
"index.production.js": "
|
|
148
|
+
"index.production.js": "37ac-117"
|
|
149
149
|
},
|
|
150
150
|
"imported": [
|
|
151
151
|
{
|
|
152
|
-
"uid": "
|
|
152
|
+
"uid": "37ac-110"
|
|
153
153
|
},
|
|
154
154
|
{
|
|
155
|
-
"uid": "
|
|
155
|
+
"uid": "37ac-112"
|
|
156
156
|
},
|
|
157
157
|
{
|
|
158
|
-
"uid": "
|
|
158
|
+
"uid": "37ac-114"
|
|
159
159
|
}
|
|
160
160
|
],
|
|
161
161
|
"importedBy": [
|
|
162
162
|
{
|
|
163
|
-
"uid": "
|
|
163
|
+
"uid": "37ac-120"
|
|
164
164
|
}
|
|
165
165
|
]
|
|
166
166
|
},
|
|
167
|
-
"
|
|
167
|
+
"37ac-118": {
|
|
168
168
|
"id": "/packages/react-store/build/esm/index.js",
|
|
169
169
|
"moduleParts": {
|
|
170
|
-
"index.production.js": "
|
|
170
|
+
"index.production.js": "37ac-119"
|
|
171
171
|
},
|
|
172
172
|
"imported": [
|
|
173
173
|
{
|
|
174
|
-
"uid": "
|
|
174
|
+
"uid": "37ac-123"
|
|
175
175
|
}
|
|
176
176
|
],
|
|
177
177
|
"importedBy": [
|
|
178
178
|
{
|
|
179
|
-
"uid": "
|
|
179
|
+
"uid": "37ac-120"
|
|
180
180
|
}
|
|
181
181
|
]
|
|
182
182
|
},
|
|
183
|
-
"
|
|
183
|
+
"37ac-120": {
|
|
184
184
|
"id": "/packages/react-router/src/index.tsx",
|
|
185
185
|
"moduleParts": {
|
|
186
|
-
"index.production.js": "
|
|
186
|
+
"index.production.js": "37ac-121"
|
|
187
187
|
},
|
|
188
188
|
"imported": [
|
|
189
189
|
{
|
|
190
|
-
"uid": "
|
|
190
|
+
"uid": "37ac-108"
|
|
191
191
|
},
|
|
192
192
|
{
|
|
193
|
-
"uid": "
|
|
193
|
+
"uid": "37ac-122"
|
|
194
194
|
},
|
|
195
195
|
{
|
|
196
|
-
"uid": "
|
|
196
|
+
"uid": "37ac-116"
|
|
197
197
|
},
|
|
198
198
|
{
|
|
199
|
-
"uid": "
|
|
199
|
+
"uid": "37ac-118"
|
|
200
200
|
}
|
|
201
201
|
],
|
|
202
202
|
"importedBy": [],
|
|
203
203
|
"isEntry": true
|
|
204
204
|
},
|
|
205
|
-
"
|
|
205
|
+
"37ac-122": {
|
|
206
206
|
"id": "react",
|
|
207
207
|
"moduleParts": {},
|
|
208
208
|
"imported": [],
|
|
209
209
|
"importedBy": [
|
|
210
210
|
{
|
|
211
|
-
"uid": "
|
|
211
|
+
"uid": "37ac-120"
|
|
212
212
|
}
|
|
213
213
|
],
|
|
214
214
|
"isExternal": true
|
|
215
215
|
},
|
|
216
|
-
"
|
|
216
|
+
"37ac-123": {
|
|
217
217
|
"id": "use-sync-external-store/shim/with-selector",
|
|
218
218
|
"moduleParts": {},
|
|
219
219
|
"imported": [],
|
|
220
220
|
"importedBy": [
|
|
221
221
|
{
|
|
222
|
-
"uid": "
|
|
222
|
+
"uid": "37ac-118"
|
|
223
223
|
}
|
|
224
224
|
],
|
|
225
225
|
"isExternal": true
|
package/build/types/index.d.ts
CHANGED
|
@@ -79,7 +79,7 @@ type RouterProps<TRouteConfig extends AnyRootRoute = RootRoute, TRoutesInfo exte
|
|
|
79
79
|
};
|
|
80
80
|
declare function RouterProvider<TRouteConfig extends AnyRootRoute = RootRoute, TRoutesInfo extends AnyRoutesInfo = DefaultRoutesInfo>({ router, ...rest }: RouterProps<TRouteConfig, TRoutesInfo>): JSX.Element;
|
|
81
81
|
declare function useRouterContext(): RegisteredRouter;
|
|
82
|
-
declare function useRouter<T = RouterStore>(track?: (state: Router['
|
|
82
|
+
declare function useRouter<T = RouterStore>(track?: (state: Router['__store']) => T, shallow?: boolean): RegisteredRouter;
|
|
83
83
|
declare function useMatches(): RouteMatch[];
|
|
84
84
|
declare function useMatch<TFrom extends keyof RegisteredRoutesInfo['routesById'], TStrict extends boolean = true, TRouteMatch = RouteMatch<RegisteredRoutesInfo, RegisteredRoutesInfo['routesById'][TFrom]>>(opts?: {
|
|
85
85
|
from: TFrom;
|
|
@@ -783,12 +783,12 @@
|
|
|
783
783
|
parseSearch: options?.parseSearch ?? defaultParseSearch,
|
|
784
784
|
fetchServerDataFn: options?.fetchServerDataFn ?? defaultFetchServerDataFn
|
|
785
785
|
};
|
|
786
|
-
this.
|
|
786
|
+
this.__store = new Store(getInitialRouterState(), {
|
|
787
787
|
onUpdate: state => {
|
|
788
788
|
this.state = state;
|
|
789
789
|
}
|
|
790
790
|
});
|
|
791
|
-
this.state = this.
|
|
791
|
+
this.state = this.__store.state;
|
|
792
792
|
this.basepath = '';
|
|
793
793
|
this.update(options);
|
|
794
794
|
|
|
@@ -808,7 +808,7 @@
|
|
|
808
808
|
}
|
|
809
809
|
}
|
|
810
810
|
reset = () => {
|
|
811
|
-
this.
|
|
811
|
+
this.__store.setState(s => Object.assign(s, getInitialRouterState()));
|
|
812
812
|
};
|
|
813
813
|
mount = () => {
|
|
814
814
|
// Mount only does anything on the client
|
|
@@ -828,7 +828,7 @@
|
|
|
828
828
|
}
|
|
829
829
|
this.history = this.options.history ?? (isServer ? createMemoryHistory() : createBrowserHistory());
|
|
830
830
|
const parsedLocation = this.#parseLocation();
|
|
831
|
-
this.
|
|
831
|
+
this.__store.setState(s => ({
|
|
832
832
|
...s,
|
|
833
833
|
latestLocation: parsedLocation,
|
|
834
834
|
currentLocation: parsedLocation
|
|
@@ -852,13 +852,10 @@
|
|
|
852
852
|
};
|
|
853
853
|
buildNext = opts => {
|
|
854
854
|
const next = this.#buildLocation(opts);
|
|
855
|
-
const
|
|
856
|
-
const __preSearchFilters = matches.map(match => match.route.options.preSearchFilters ?? []).flat().filter(Boolean);
|
|
857
|
-
const __postSearchFilters = matches.map(match => match.route.options.postSearchFilters ?? []).flat().filter(Boolean);
|
|
855
|
+
const __matches = this.matchRoutes(next.pathname);
|
|
858
856
|
return this.#buildLocation({
|
|
859
857
|
...opts,
|
|
860
|
-
|
|
861
|
-
__postSearchFilters
|
|
858
|
+
__matches
|
|
862
859
|
});
|
|
863
860
|
};
|
|
864
861
|
cancelMatches = () => {
|
|
@@ -880,10 +877,10 @@
|
|
|
880
877
|
// Cancel any pending matches
|
|
881
878
|
this.cancelMatches();
|
|
882
879
|
let matches;
|
|
883
|
-
this.
|
|
880
|
+
this.__store.batch(() => {
|
|
884
881
|
if (opts?.next) {
|
|
885
882
|
// Ingest the new location
|
|
886
|
-
this.
|
|
883
|
+
this.__store.setState(s => ({
|
|
887
884
|
...s,
|
|
888
885
|
latestLocation: opts.next
|
|
889
886
|
}));
|
|
@@ -893,7 +890,7 @@
|
|
|
893
890
|
matches = this.matchRoutes(this.state.latestLocation.pathname, {
|
|
894
891
|
strictParseParams: true
|
|
895
892
|
});
|
|
896
|
-
this.
|
|
893
|
+
this.__store.setState(s => ({
|
|
897
894
|
...s,
|
|
898
895
|
status: 'pending',
|
|
899
896
|
pendingMatches: matches,
|
|
@@ -932,7 +929,7 @@
|
|
|
932
929
|
|
|
933
930
|
// Clear non-loading error states when match leaves
|
|
934
931
|
if (d.state.status === 'error') {
|
|
935
|
-
this.
|
|
932
|
+
this.__store.setState(s => ({
|
|
936
933
|
...s,
|
|
937
934
|
status: 'idle',
|
|
938
935
|
error: undefined
|
|
@@ -952,7 +949,7 @@
|
|
|
952
949
|
});
|
|
953
950
|
});
|
|
954
951
|
const prevLocation = this.state.currentLocation;
|
|
955
|
-
this.
|
|
952
|
+
this.__store.setState(s => ({
|
|
956
953
|
...s,
|
|
957
954
|
status: 'idle',
|
|
958
955
|
currentLocation: this.state.latestLocation,
|
|
@@ -1273,7 +1270,7 @@
|
|
|
1273
1270
|
};
|
|
1274
1271
|
};
|
|
1275
1272
|
hydrate = dehydratedRouter => {
|
|
1276
|
-
this.
|
|
1273
|
+
this.__store.setState(s => {
|
|
1277
1274
|
// Match the routes
|
|
1278
1275
|
const currentMatches = this.matchRoutes(dehydratedRouter.state.latestLocation.pathname, {
|
|
1279
1276
|
strictParseParams: true
|
|
@@ -1281,7 +1278,7 @@
|
|
|
1281
1278
|
currentMatches.forEach((match, index) => {
|
|
1282
1279
|
const dehydratedMatch = dehydratedRouter.state.currentMatches[index];
|
|
1283
1280
|
invariant(dehydratedMatch && dehydratedMatch.id === match.id, 'Oh no! There was a hydration mismatch when attempting to hydrate the state of the router! 😬');
|
|
1284
|
-
match.
|
|
1281
|
+
match.__store.setState(s => ({
|
|
1285
1282
|
...s,
|
|
1286
1283
|
...dehydratedMatch.state
|
|
1287
1284
|
}));
|
|
@@ -1373,29 +1370,33 @@
|
|
|
1373
1370
|
const fromMatches = this.matchRoutes(this.state.latestLocation.pathname, {
|
|
1374
1371
|
strictParseParams: true
|
|
1375
1372
|
});
|
|
1376
|
-
const toMatches = this.matchRoutes(pathname);
|
|
1377
1373
|
const prevParams = {
|
|
1378
1374
|
...last(fromMatches)?.params
|
|
1379
1375
|
};
|
|
1380
1376
|
let nextParams = (dest.params ?? true) === true ? prevParams : functionalUpdate(dest.params, prevParams);
|
|
1381
1377
|
if (nextParams) {
|
|
1382
|
-
|
|
1383
|
-
|
|
1378
|
+
dest.__matches?.map(d => d.route.options.stringifyParams).filter(Boolean).forEach(fn => {
|
|
1379
|
+
nextParams = {
|
|
1380
|
+
...nextParams,
|
|
1381
|
+
...fn(nextParams)
|
|
1382
|
+
};
|
|
1384
1383
|
});
|
|
1385
1384
|
}
|
|
1386
1385
|
pathname = interpolatePath(pathname, nextParams ?? {});
|
|
1386
|
+
const preSearchFilters = dest.__matches?.map(match => match.route.options.preSearchFilters ?? []).flat().filter(Boolean) ?? [];
|
|
1387
|
+
const postSearchFilters = dest.__matches?.map(match => match.route.options.postSearchFilters ?? []).flat().filter(Boolean) ?? [];
|
|
1387
1388
|
|
|
1388
1389
|
// Pre filters first
|
|
1389
|
-
const preFilteredSearch =
|
|
1390
|
+
const preFilteredSearch = preSearchFilters?.length ? preSearchFilters?.reduce((prev, next) => next(prev), this.state.latestLocation.search) : this.state.latestLocation.search;
|
|
1390
1391
|
|
|
1391
1392
|
// Then the link/navigate function
|
|
1392
1393
|
const destSearch = dest.search === true ? preFilteredSearch // Preserve resolvedFrom true
|
|
1393
1394
|
: dest.search ? functionalUpdate(dest.search, preFilteredSearch) ?? {} // Updater
|
|
1394
|
-
:
|
|
1395
|
+
: preSearchFilters?.length ? preFilteredSearch // Preserve resolvedFrom filters
|
|
1395
1396
|
: {};
|
|
1396
1397
|
|
|
1397
1398
|
// Then post filters
|
|
1398
|
-
const postFilteredSearch =
|
|
1399
|
+
const postFilteredSearch = postSearchFilters?.length ? postSearchFilters.reduce((prev, next) => next(prev), destSearch) : destSearch;
|
|
1399
1400
|
const search = replaceEqualDeep(this.state.latestLocation.search, postFilteredSearch);
|
|
1400
1401
|
const searchStr = this.options.stringifySearch(search);
|
|
1401
1402
|
let hash = dest.hash === true ? this.state.latestLocation.hash : functionalUpdate(dest.hash, this.state.latestLocation.hash);
|
|
@@ -1471,7 +1472,7 @@
|
|
|
1471
1472
|
id: opts.id,
|
|
1472
1473
|
pathname: opts.pathname,
|
|
1473
1474
|
params: opts.params,
|
|
1474
|
-
|
|
1475
|
+
__store: new Store({
|
|
1475
1476
|
updatedAt: 0,
|
|
1476
1477
|
routeSearch: {},
|
|
1477
1478
|
search: {},
|
|
@@ -1482,7 +1483,7 @@
|
|
|
1482
1483
|
}
|
|
1483
1484
|
})
|
|
1484
1485
|
});
|
|
1485
|
-
this.state = this.
|
|
1486
|
+
this.state = this.__store.state;
|
|
1486
1487
|
componentTypes.map(async type => {
|
|
1487
1488
|
const component = this.route.options[type];
|
|
1488
1489
|
if (typeof this[type] !== 'function') {
|
|
@@ -1490,7 +1491,7 @@
|
|
|
1490
1491
|
}
|
|
1491
1492
|
});
|
|
1492
1493
|
if (this.state.status === 'idle' && !this.#hasLoaders()) {
|
|
1493
|
-
this.
|
|
1494
|
+
this.__store.setState(s => ({
|
|
1494
1495
|
...s,
|
|
1495
1496
|
status: 'success'
|
|
1496
1497
|
}));
|
|
@@ -1510,7 +1511,7 @@
|
|
|
1510
1511
|
});
|
|
1511
1512
|
this.context = context;
|
|
1512
1513
|
this.routeContext = routeContext;
|
|
1513
|
-
this.
|
|
1514
|
+
this.__store.setState(s => ({
|
|
1514
1515
|
...s,
|
|
1515
1516
|
routeSearch: replaceEqualDeep(s.routeSearch, routeSearch),
|
|
1516
1517
|
search: replaceEqualDeep(s.search, search)
|
|
@@ -1581,7 +1582,7 @@
|
|
|
1581
1582
|
return;
|
|
1582
1583
|
}
|
|
1583
1584
|
this.route.options.onError?.(err);
|
|
1584
|
-
this.
|
|
1585
|
+
this.__store.setState(s => ({
|
|
1585
1586
|
...s,
|
|
1586
1587
|
status: 'error',
|
|
1587
1588
|
error: err
|
|
@@ -1615,7 +1616,7 @@
|
|
|
1615
1616
|
// to a loading state again. Otherwise, keep it
|
|
1616
1617
|
// as loading or resolved
|
|
1617
1618
|
if (this.state.status === 'idle') {
|
|
1618
|
-
this.
|
|
1619
|
+
this.__store.setState(s => ({
|
|
1619
1620
|
...s,
|
|
1620
1621
|
status: 'pending'
|
|
1621
1622
|
}));
|
|
@@ -1648,7 +1649,7 @@
|
|
|
1648
1649
|
try {
|
|
1649
1650
|
await Promise.all([componentsPromise, dataPromise]);
|
|
1650
1651
|
if (latestPromise = checkLatest()) return await latestPromise;
|
|
1651
|
-
this.
|
|
1652
|
+
this.__store.setState(s => ({
|
|
1652
1653
|
...s,
|
|
1653
1654
|
error: undefined,
|
|
1654
1655
|
status: 'success',
|
|
@@ -1661,7 +1662,7 @@
|
|
|
1661
1662
|
}
|
|
1662
1663
|
this.route.options.onLoadError?.(err);
|
|
1663
1664
|
this.route.options.onError?.(err);
|
|
1664
|
-
this.
|
|
1665
|
+
this.__store.setState(s => ({
|
|
1665
1666
|
...s,
|
|
1666
1667
|
error: err,
|
|
1667
1668
|
status: 'error',
|
|
@@ -1880,7 +1881,7 @@
|
|
|
1880
1881
|
...rest
|
|
1881
1882
|
}) {
|
|
1882
1883
|
router.update(rest);
|
|
1883
|
-
const currentMatches = useStore(router.
|
|
1884
|
+
const currentMatches = useStore(router.__store, s => s.currentMatches);
|
|
1884
1885
|
React__namespace.useEffect(router.mount, [router]);
|
|
1885
1886
|
return /*#__PURE__*/React__namespace.createElement(routerContext.Provider, {
|
|
1886
1887
|
value: {
|
|
@@ -1898,12 +1899,12 @@
|
|
|
1898
1899
|
function useRouterContext() {
|
|
1899
1900
|
const value = React__namespace.useContext(routerContext);
|
|
1900
1901
|
warning(value, 'useRouter must be used inside a <Router> component!');
|
|
1901
|
-
useStore(value.router.
|
|
1902
|
+
useStore(value.router.__store);
|
|
1902
1903
|
return value.router;
|
|
1903
1904
|
}
|
|
1904
1905
|
function useRouter(track, shallow) {
|
|
1905
1906
|
const router = useRouterContext();
|
|
1906
|
-
useStore(router.
|
|
1907
|
+
useStore(router.__store, track, shallow);
|
|
1907
1908
|
return router;
|
|
1908
1909
|
}
|
|
1909
1910
|
function useMatches() {
|
|
@@ -1917,7 +1918,7 @@
|
|
|
1917
1918
|
if (opts?.strict ?? true) {
|
|
1918
1919
|
invariant(nearestMatch.route.id == match?.route.id, `useMatch("${match?.route.id}") is being called in a component that is meant to render the '${nearestMatch.route.id}' route. Did you mean to 'useMatch("${match?.route.id}", { strict: false })' or 'useRoute("${match?.route.id}")' instead?`);
|
|
1919
1920
|
}
|
|
1920
|
-
useStore(match.
|
|
1921
|
+
useStore(match.__store, d => opts?.track?.(match) ?? match, opts?.shallow);
|
|
1921
1922
|
return match;
|
|
1922
1923
|
}
|
|
1923
1924
|
function useRoute(routeId) {
|
|
@@ -1927,13 +1928,17 @@
|
|
|
1927
1928
|
return resolvedRoute;
|
|
1928
1929
|
}
|
|
1929
1930
|
function useSearch(opts) {
|
|
1930
|
-
const
|
|
1931
|
-
|
|
1931
|
+
const {
|
|
1932
|
+
track,
|
|
1933
|
+
...matchOpts
|
|
1934
|
+
} = opts;
|
|
1935
|
+
const match = useMatch(matchOpts);
|
|
1936
|
+
useStore(match.__store, d => opts?.track?.(d.search) ?? d.search, true);
|
|
1932
1937
|
return match.state.search;
|
|
1933
1938
|
}
|
|
1934
1939
|
function useParams(opts) {
|
|
1935
1940
|
const router = useRouterContext();
|
|
1936
|
-
useStore(router.
|
|
1941
|
+
useStore(router.__store, d => {
|
|
1937
1942
|
const params = last(d.currentMatches)?.params;
|
|
1938
1943
|
return opts?.track?.(params) ?? params;
|
|
1939
1944
|
}, true);
|
|
@@ -1989,7 +1994,7 @@
|
|
|
1989
1994
|
match
|
|
1990
1995
|
}) {
|
|
1991
1996
|
const router = useRouterContext();
|
|
1992
|
-
useStore(match.
|
|
1997
|
+
useStore(match.__store, store => [store.status, store.error], true);
|
|
1993
1998
|
const defaultPending = React__namespace.useCallback(() => null, []);
|
|
1994
1999
|
const Inner = React__namespace.useCallback(props => {
|
|
1995
2000
|
if (props.match.state.status === 'error') {
|