@tanstack/react-router 0.0.1-beta.159 → 0.0.1-beta.160
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/stats-html.html
CHANGED
|
@@ -4024,7 +4024,7 @@ var drawChart = (function (exports) {
|
|
|
4024
4024
|
</script>
|
|
4025
4025
|
<script>
|
|
4026
4026
|
/*<!--*/
|
|
4027
|
-
const data = {"version":2,"tree":{"name":"root","children":[{"name":"index.production.js","children":[{"uid":"
|
|
4027
|
+
const data = {"version":2,"tree":{"name":"root","children":[{"name":"index.production.js","children":[{"uid":"284f-151","name":"\u0000rollupPluginBabelHelpers.js"},{"name":"packages","children":[{"name":"store/build/esm/index.js","uid":"284f-153"},{"name":"react-store/build/esm/index.js","uid":"284f-155"},{"name":"router-core/build/esm/index.js","uid":"284f-161"},{"name":"react-router/src/index.tsx","uid":"284f-163"}]},{"name":"node_modules/.pnpm","children":[{"name":"tiny-invariant@1.3.1/node_modules/tiny-invariant/dist/esm/tiny-invariant.js","uid":"284f-157"},{"name":"tiny-warning@1.0.3/node_modules/tiny-warning/dist/tiny-warning.esm.js","uid":"284f-159"}]}]}],"isRoot":true},"nodeParts":{"284f-151":{"renderedLength":429,"gzipLength":238,"brotliLength":0,"mainUid":"284f-150"},"284f-153":{"renderedLength":1843,"gzipLength":644,"brotliLength":0,"mainUid":"284f-152"},"284f-155":{"renderedLength":1006,"gzipLength":479,"brotliLength":0,"mainUid":"284f-154"},"284f-157":{"renderedLength":181,"gzipLength":129,"brotliLength":0,"mainUid":"284f-156"},"284f-159":{"renderedLength":44,"gzipLength":62,"brotliLength":0,"mainUid":"284f-158"},"284f-161":{"renderedLength":56742,"gzipLength":13356,"brotliLength":0,"mainUid":"284f-160"},"284f-163":{"renderedLength":17095,"gzipLength":3814,"brotliLength":0,"mainUid":"284f-162"}},"nodeMetas":{"284f-150":{"id":"\u0000rollupPluginBabelHelpers.js","moduleParts":{"index.production.js":"284f-151"},"imported":[],"importedBy":[{"uid":"284f-162"}]},"284f-152":{"id":"/packages/store/build/esm/index.js","moduleParts":{"index.production.js":"284f-153"},"imported":[],"importedBy":[{"uid":"284f-154"}]},"284f-154":{"id":"/packages/react-store/build/esm/index.js","moduleParts":{"index.production.js":"284f-155"},"imported":[{"uid":"284f-165"},{"uid":"284f-152"}],"importedBy":[{"uid":"284f-162"},{"uid":"284f-160"}]},"284f-156":{"id":"/node_modules/.pnpm/tiny-invariant@1.3.1/node_modules/tiny-invariant/dist/esm/tiny-invariant.js","moduleParts":{"index.production.js":"284f-157"},"imported":[],"importedBy":[{"uid":"284f-162"},{"uid":"284f-160"}]},"284f-158":{"id":"/node_modules/.pnpm/tiny-warning@1.0.3/node_modules/tiny-warning/dist/tiny-warning.esm.js","moduleParts":{"index.production.js":"284f-159"},"imported":[],"importedBy":[{"uid":"284f-162"},{"uid":"284f-160"}]},"284f-160":{"id":"/packages/router-core/build/esm/index.js","moduleParts":{"index.production.js":"284f-161"},"imported":[{"uid":"284f-156"},{"uid":"284f-158"},{"uid":"284f-154"}],"importedBy":[{"uid":"284f-162"}]},"284f-162":{"id":"/packages/react-router/src/index.tsx","moduleParts":{"index.production.js":"284f-163"},"imported":[{"uid":"284f-150"},{"uid":"284f-164"},{"uid":"284f-154"},{"uid":"284f-156"},{"uid":"284f-158"},{"uid":"284f-160"}],"importedBy":[],"isEntry":true},"284f-164":{"id":"react","moduleParts":{},"imported":[],"importedBy":[{"uid":"284f-162"}],"isExternal":true},"284f-165":{"id":"use-sync-external-store/shim/with-selector","moduleParts":{},"imported":[],"importedBy":[{"uid":"284f-154"}],"isExternal":true}},"env":{"rollup":"2.79.1"},"options":{"gzip":true,"brotli":false,"sourcemap":false}};
|
|
4028
4028
|
|
|
4029
4029
|
const run = () => {
|
|
4030
4030
|
const width = window.innerWidth;
|
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": "284f-167",
|
|
11
11
|
"name": "\u0000rollupPluginBabelHelpers.js"
|
|
12
12
|
},
|
|
13
13
|
{
|
|
@@ -15,19 +15,19 @@
|
|
|
15
15
|
"children": [
|
|
16
16
|
{
|
|
17
17
|
"name": "store/build/esm/index.js",
|
|
18
|
-
"uid": "
|
|
18
|
+
"uid": "284f-169"
|
|
19
19
|
},
|
|
20
20
|
{
|
|
21
21
|
"name": "react-store/build/esm/index.js",
|
|
22
|
-
"uid": "
|
|
22
|
+
"uid": "284f-171"
|
|
23
23
|
},
|
|
24
24
|
{
|
|
25
25
|
"name": "router-core/build/esm/index.js",
|
|
26
|
-
"uid": "
|
|
26
|
+
"uid": "284f-177"
|
|
27
27
|
},
|
|
28
28
|
{
|
|
29
29
|
"name": "react-router/src/index.tsx",
|
|
30
|
-
"uid": "
|
|
30
|
+
"uid": "284f-179"
|
|
31
31
|
}
|
|
32
32
|
]
|
|
33
33
|
},
|
|
@@ -36,11 +36,11 @@
|
|
|
36
36
|
"children": [
|
|
37
37
|
{
|
|
38
38
|
"name": "tiny-invariant@1.3.1/node_modules/tiny-invariant/dist/esm/tiny-invariant.js",
|
|
39
|
-
"uid": "
|
|
39
|
+
"uid": "284f-173"
|
|
40
40
|
},
|
|
41
41
|
{
|
|
42
42
|
"name": "tiny-warning@1.0.3/node_modules/tiny-warning/dist/tiny-warning.esm.js",
|
|
43
|
-
"uid": "
|
|
43
|
+
"uid": "284f-175"
|
|
44
44
|
}
|
|
45
45
|
]
|
|
46
46
|
}
|
|
@@ -50,194 +50,194 @@
|
|
|
50
50
|
"isRoot": true
|
|
51
51
|
},
|
|
52
52
|
"nodeParts": {
|
|
53
|
-
"
|
|
53
|
+
"284f-167": {
|
|
54
54
|
"renderedLength": 429,
|
|
55
55
|
"gzipLength": 238,
|
|
56
56
|
"brotliLength": 0,
|
|
57
|
-
"mainUid": "
|
|
57
|
+
"mainUid": "284f-166"
|
|
58
58
|
},
|
|
59
|
-
"
|
|
59
|
+
"284f-169": {
|
|
60
60
|
"renderedLength": 1843,
|
|
61
61
|
"gzipLength": 644,
|
|
62
62
|
"brotliLength": 0,
|
|
63
|
-
"mainUid": "
|
|
63
|
+
"mainUid": "284f-168"
|
|
64
64
|
},
|
|
65
|
-
"
|
|
65
|
+
"284f-171": {
|
|
66
66
|
"renderedLength": 1006,
|
|
67
67
|
"gzipLength": 479,
|
|
68
68
|
"brotliLength": 0,
|
|
69
|
-
"mainUid": "
|
|
69
|
+
"mainUid": "284f-170"
|
|
70
70
|
},
|
|
71
|
-
"
|
|
71
|
+
"284f-173": {
|
|
72
72
|
"renderedLength": 181,
|
|
73
73
|
"gzipLength": 129,
|
|
74
74
|
"brotliLength": 0,
|
|
75
|
-
"mainUid": "
|
|
75
|
+
"mainUid": "284f-172"
|
|
76
76
|
},
|
|
77
|
-
"
|
|
77
|
+
"284f-175": {
|
|
78
78
|
"renderedLength": 44,
|
|
79
79
|
"gzipLength": 62,
|
|
80
80
|
"brotliLength": 0,
|
|
81
|
-
"mainUid": "
|
|
81
|
+
"mainUid": "284f-174"
|
|
82
82
|
},
|
|
83
|
-
"
|
|
84
|
-
"renderedLength":
|
|
85
|
-
"gzipLength":
|
|
83
|
+
"284f-177": {
|
|
84
|
+
"renderedLength": 56742,
|
|
85
|
+
"gzipLength": 13356,
|
|
86
86
|
"brotliLength": 0,
|
|
87
|
-
"mainUid": "
|
|
87
|
+
"mainUid": "284f-176"
|
|
88
88
|
},
|
|
89
|
-
"
|
|
89
|
+
"284f-179": {
|
|
90
90
|
"renderedLength": 17095,
|
|
91
91
|
"gzipLength": 3814,
|
|
92
92
|
"brotliLength": 0,
|
|
93
|
-
"mainUid": "
|
|
93
|
+
"mainUid": "284f-178"
|
|
94
94
|
}
|
|
95
95
|
},
|
|
96
96
|
"nodeMetas": {
|
|
97
|
-
"
|
|
97
|
+
"284f-166": {
|
|
98
98
|
"id": "\u0000rollupPluginBabelHelpers.js",
|
|
99
99
|
"moduleParts": {
|
|
100
|
-
"index.production.js": "
|
|
100
|
+
"index.production.js": "284f-167"
|
|
101
101
|
},
|
|
102
102
|
"imported": [],
|
|
103
103
|
"importedBy": [
|
|
104
104
|
{
|
|
105
|
-
"uid": "
|
|
105
|
+
"uid": "284f-178"
|
|
106
106
|
}
|
|
107
107
|
]
|
|
108
108
|
},
|
|
109
|
-
"
|
|
109
|
+
"284f-168": {
|
|
110
110
|
"id": "/packages/store/build/esm/index.js",
|
|
111
111
|
"moduleParts": {
|
|
112
|
-
"index.production.js": "
|
|
112
|
+
"index.production.js": "284f-169"
|
|
113
113
|
},
|
|
114
114
|
"imported": [],
|
|
115
115
|
"importedBy": [
|
|
116
116
|
{
|
|
117
|
-
"uid": "
|
|
117
|
+
"uid": "284f-170"
|
|
118
118
|
}
|
|
119
119
|
]
|
|
120
120
|
},
|
|
121
|
-
"
|
|
121
|
+
"284f-170": {
|
|
122
122
|
"id": "/packages/react-store/build/esm/index.js",
|
|
123
123
|
"moduleParts": {
|
|
124
|
-
"index.production.js": "
|
|
124
|
+
"index.production.js": "284f-171"
|
|
125
125
|
},
|
|
126
126
|
"imported": [
|
|
127
127
|
{
|
|
128
|
-
"uid": "
|
|
128
|
+
"uid": "284f-181"
|
|
129
129
|
},
|
|
130
130
|
{
|
|
131
|
-
"uid": "
|
|
131
|
+
"uid": "284f-168"
|
|
132
132
|
}
|
|
133
133
|
],
|
|
134
134
|
"importedBy": [
|
|
135
135
|
{
|
|
136
|
-
"uid": "
|
|
136
|
+
"uid": "284f-178"
|
|
137
137
|
},
|
|
138
138
|
{
|
|
139
|
-
"uid": "
|
|
139
|
+
"uid": "284f-176"
|
|
140
140
|
}
|
|
141
141
|
]
|
|
142
142
|
},
|
|
143
|
-
"
|
|
143
|
+
"284f-172": {
|
|
144
144
|
"id": "/node_modules/.pnpm/tiny-invariant@1.3.1/node_modules/tiny-invariant/dist/esm/tiny-invariant.js",
|
|
145
145
|
"moduleParts": {
|
|
146
|
-
"index.production.js": "
|
|
146
|
+
"index.production.js": "284f-173"
|
|
147
147
|
},
|
|
148
148
|
"imported": [],
|
|
149
149
|
"importedBy": [
|
|
150
150
|
{
|
|
151
|
-
"uid": "
|
|
151
|
+
"uid": "284f-178"
|
|
152
152
|
},
|
|
153
153
|
{
|
|
154
|
-
"uid": "
|
|
154
|
+
"uid": "284f-176"
|
|
155
155
|
}
|
|
156
156
|
]
|
|
157
157
|
},
|
|
158
|
-
"
|
|
158
|
+
"284f-174": {
|
|
159
159
|
"id": "/node_modules/.pnpm/tiny-warning@1.0.3/node_modules/tiny-warning/dist/tiny-warning.esm.js",
|
|
160
160
|
"moduleParts": {
|
|
161
|
-
"index.production.js": "
|
|
161
|
+
"index.production.js": "284f-175"
|
|
162
162
|
},
|
|
163
163
|
"imported": [],
|
|
164
164
|
"importedBy": [
|
|
165
165
|
{
|
|
166
|
-
"uid": "
|
|
166
|
+
"uid": "284f-178"
|
|
167
167
|
},
|
|
168
168
|
{
|
|
169
|
-
"uid": "
|
|
169
|
+
"uid": "284f-176"
|
|
170
170
|
}
|
|
171
171
|
]
|
|
172
172
|
},
|
|
173
|
-
"
|
|
173
|
+
"284f-176": {
|
|
174
174
|
"id": "/packages/router-core/build/esm/index.js",
|
|
175
175
|
"moduleParts": {
|
|
176
|
-
"index.production.js": "
|
|
176
|
+
"index.production.js": "284f-177"
|
|
177
177
|
},
|
|
178
178
|
"imported": [
|
|
179
179
|
{
|
|
180
|
-
"uid": "
|
|
180
|
+
"uid": "284f-172"
|
|
181
181
|
},
|
|
182
182
|
{
|
|
183
|
-
"uid": "
|
|
183
|
+
"uid": "284f-174"
|
|
184
184
|
},
|
|
185
185
|
{
|
|
186
|
-
"uid": "
|
|
186
|
+
"uid": "284f-170"
|
|
187
187
|
}
|
|
188
188
|
],
|
|
189
189
|
"importedBy": [
|
|
190
190
|
{
|
|
191
|
-
"uid": "
|
|
191
|
+
"uid": "284f-178"
|
|
192
192
|
}
|
|
193
193
|
]
|
|
194
194
|
},
|
|
195
|
-
"
|
|
195
|
+
"284f-178": {
|
|
196
196
|
"id": "/packages/react-router/src/index.tsx",
|
|
197
197
|
"moduleParts": {
|
|
198
|
-
"index.production.js": "
|
|
198
|
+
"index.production.js": "284f-179"
|
|
199
199
|
},
|
|
200
200
|
"imported": [
|
|
201
201
|
{
|
|
202
|
-
"uid": "
|
|
202
|
+
"uid": "284f-166"
|
|
203
203
|
},
|
|
204
204
|
{
|
|
205
|
-
"uid": "
|
|
205
|
+
"uid": "284f-180"
|
|
206
206
|
},
|
|
207
207
|
{
|
|
208
|
-
"uid": "
|
|
208
|
+
"uid": "284f-170"
|
|
209
209
|
},
|
|
210
210
|
{
|
|
211
|
-
"uid": "
|
|
211
|
+
"uid": "284f-172"
|
|
212
212
|
},
|
|
213
213
|
{
|
|
214
|
-
"uid": "
|
|
214
|
+
"uid": "284f-174"
|
|
215
215
|
},
|
|
216
216
|
{
|
|
217
|
-
"uid": "
|
|
217
|
+
"uid": "284f-176"
|
|
218
218
|
}
|
|
219
219
|
],
|
|
220
220
|
"importedBy": [],
|
|
221
221
|
"isEntry": true
|
|
222
222
|
},
|
|
223
|
-
"
|
|
223
|
+
"284f-180": {
|
|
224
224
|
"id": "react",
|
|
225
225
|
"moduleParts": {},
|
|
226
226
|
"imported": [],
|
|
227
227
|
"importedBy": [
|
|
228
228
|
{
|
|
229
|
-
"uid": "
|
|
229
|
+
"uid": "284f-178"
|
|
230
230
|
}
|
|
231
231
|
],
|
|
232
232
|
"isExternal": true
|
|
233
233
|
},
|
|
234
|
-
"
|
|
234
|
+
"284f-181": {
|
|
235
235
|
"id": "use-sync-external-store/shim/with-selector",
|
|
236
236
|
"moduleParts": {},
|
|
237
237
|
"imported": [],
|
|
238
238
|
"importedBy": [
|
|
239
239
|
{
|
|
240
|
-
"uid": "
|
|
240
|
+
"uid": "284f-170"
|
|
241
241
|
}
|
|
242
242
|
],
|
|
243
243
|
"isExternal": true
|
|
@@ -724,8 +724,6 @@
|
|
|
724
724
|
|
|
725
725
|
const rootRouteId = '__root__';
|
|
726
726
|
|
|
727
|
-
// | ParseParamsObj<TPath, TParams>
|
|
728
|
-
|
|
729
727
|
// The parse type here allows a zod schema to be passed directly to the validator
|
|
730
728
|
|
|
731
729
|
class Route {
|
|
@@ -892,25 +890,27 @@
|
|
|
892
890
|
this.__store = new Store(getInitialRouterState(), {
|
|
893
891
|
onUpdate: () => {
|
|
894
892
|
const prev = this.state;
|
|
895
|
-
|
|
896
|
-
|
|
893
|
+
const next = this.__store.state;
|
|
894
|
+
console.log(Object.values(next.matchesById).find(d => d.status === 'error'));
|
|
895
|
+
const matchesByIdChanged = prev.matchesById !== next.matchesById;
|
|
897
896
|
let matchesChanged;
|
|
898
897
|
let pendingMatchesChanged;
|
|
899
898
|
if (!matchesByIdChanged) {
|
|
900
|
-
matchesChanged = prev.matchIds.length !==
|
|
901
|
-
pendingMatchesChanged = prev.pendingMatchIds.length !==
|
|
899
|
+
matchesChanged = prev.matchIds.length !== next.matchIds.length || prev.matchIds.some((d, i) => d !== next.matchIds[i]);
|
|
900
|
+
pendingMatchesChanged = prev.pendingMatchIds.length !== next.pendingMatchIds.length || prev.pendingMatchIds.some((d, i) => d !== next.pendingMatchIds[i]);
|
|
902
901
|
}
|
|
903
902
|
if (matchesByIdChanged || matchesChanged) {
|
|
904
|
-
|
|
905
|
-
return
|
|
903
|
+
next.matches = next.matchIds.map(id => {
|
|
904
|
+
return next.matchesById[id];
|
|
906
905
|
});
|
|
907
906
|
}
|
|
908
907
|
if (matchesByIdChanged || pendingMatchesChanged) {
|
|
909
|
-
|
|
910
|
-
return
|
|
908
|
+
next.pendingMatches = next.pendingMatchIds.map(id => {
|
|
909
|
+
return next.matchesById[id];
|
|
911
910
|
});
|
|
912
911
|
}
|
|
913
|
-
|
|
912
|
+
next.isFetching = [...next.matches, ...next.pendingMatches].some(d => d.isFetching);
|
|
913
|
+
this.state = next;
|
|
914
914
|
},
|
|
915
915
|
defaultPriority: 'low'
|
|
916
916
|
});
|
|
@@ -991,11 +991,12 @@
|
|
|
991
991
|
cancelMatch = id => {
|
|
992
992
|
this.getRouteMatch(id)?.abortController?.abort();
|
|
993
993
|
};
|
|
994
|
-
safeLoad = opts => {
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
994
|
+
safeLoad = async opts => {
|
|
995
|
+
try {
|
|
996
|
+
return this.load(opts);
|
|
997
|
+
} catch (err) {
|
|
998
|
+
// Don't do anything
|
|
999
|
+
}
|
|
999
1000
|
};
|
|
1000
1001
|
latestLoadPromise = Promise.resolve();
|
|
1001
1002
|
load = async opts => {
|
|
@@ -1032,11 +1033,16 @@
|
|
|
1032
1033
|
});
|
|
1033
1034
|
try {
|
|
1034
1035
|
// Load the matches
|
|
1035
|
-
|
|
1036
|
+
try {
|
|
1037
|
+
await this.loadMatches(pendingMatches);
|
|
1038
|
+
} catch (err) {
|
|
1039
|
+
// swallow this error, since we'll display the
|
|
1040
|
+
// errors on the route components
|
|
1041
|
+
}
|
|
1036
1042
|
|
|
1037
1043
|
// Only apply the latest transition
|
|
1038
1044
|
if (latestPromise = checkLatest()) {
|
|
1039
|
-
return
|
|
1045
|
+
return latestPromise;
|
|
1040
1046
|
}
|
|
1041
1047
|
const prevLocation = this.state.resolvedLocation;
|
|
1042
1048
|
this.__store.setState(s => ({
|
|
@@ -1053,7 +1059,7 @@
|
|
|
1053
1059
|
} catch (err) {
|
|
1054
1060
|
// Only apply the latest transition
|
|
1055
1061
|
if (latestPromise = checkLatest()) {
|
|
1056
|
-
return
|
|
1062
|
+
return latestPromise;
|
|
1057
1063
|
}
|
|
1058
1064
|
reject(err);
|
|
1059
1065
|
}
|
|
@@ -1312,6 +1318,7 @@
|
|
|
1312
1318
|
throw errorHandlerErr;
|
|
1313
1319
|
}
|
|
1314
1320
|
}
|
|
1321
|
+
console.log('set error');
|
|
1315
1322
|
this.setRouteMatch(match.id, s => ({
|
|
1316
1323
|
...s,
|
|
1317
1324
|
error: err,
|
|
@@ -1364,19 +1371,8 @@
|
|
|
1364
1371
|
const latest = this.getRouteMatch(match.id);
|
|
1365
1372
|
return latest && latest.fetchedAt !== fetchedAt ? latest.loadPromise : undefined;
|
|
1366
1373
|
};
|
|
1367
|
-
const
|
|
1374
|
+
const load = async () => {
|
|
1368
1375
|
let latestPromise;
|
|
1369
|
-
const componentsPromise = Promise.all(componentTypes.map(async type => {
|
|
1370
|
-
const component = route.options[type];
|
|
1371
|
-
if (component?.preload) {
|
|
1372
|
-
await component.preload();
|
|
1373
|
-
}
|
|
1374
|
-
}));
|
|
1375
|
-
const loaderPromise = route.options.loader?.({
|
|
1376
|
-
...match,
|
|
1377
|
-
preload: !!opts?.preload,
|
|
1378
|
-
parentMatchPromise
|
|
1379
|
-
});
|
|
1380
1376
|
const handleError = err => {
|
|
1381
1377
|
if (isRedirect(err)) {
|
|
1382
1378
|
if (!opts?.preload) {
|
|
@@ -1387,33 +1383,46 @@
|
|
|
1387
1383
|
return false;
|
|
1388
1384
|
};
|
|
1389
1385
|
try {
|
|
1386
|
+
const componentsPromise = Promise.all(componentTypes.map(async type => {
|
|
1387
|
+
const component = route.options[type];
|
|
1388
|
+
if (component?.preload) {
|
|
1389
|
+
await component.preload();
|
|
1390
|
+
}
|
|
1391
|
+
}));
|
|
1392
|
+
const loaderPromise = route.options.loader?.({
|
|
1393
|
+
...match,
|
|
1394
|
+
preload: !!opts?.preload,
|
|
1395
|
+
parentMatchPromise
|
|
1396
|
+
});
|
|
1390
1397
|
const [_, loader] = await Promise.all([componentsPromise, loaderPromise]);
|
|
1391
1398
|
if (latestPromise = checkLatest()) return await latestPromise;
|
|
1392
1399
|
this.setRouteMatchData(match.id, () => loader, opts);
|
|
1393
|
-
} catch (
|
|
1400
|
+
} catch (loaderError) {
|
|
1394
1401
|
if (latestPromise = checkLatest()) return await latestPromise;
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
}
|
|
1398
|
-
const errorHandler = route.options.onLoadError ?? route.options.onError;
|
|
1399
|
-
let caughtError = err;
|
|
1402
|
+
handleError(loaderError);
|
|
1403
|
+
let error = loaderError;
|
|
1400
1404
|
try {
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
return;
|
|
1405
|
+
if (route.options.onLoadError) {
|
|
1406
|
+
route.options.onLoadError?.(loaderError);
|
|
1407
|
+
} else {
|
|
1408
|
+
route.options.onError?.(loaderError);
|
|
1406
1409
|
}
|
|
1410
|
+
} catch (errorHandlerErr) {
|
|
1411
|
+
error = errorHandlerErr;
|
|
1412
|
+
handleError(error);
|
|
1407
1413
|
}
|
|
1414
|
+
console.log('set error');
|
|
1408
1415
|
this.setRouteMatch(match.id, s => ({
|
|
1409
1416
|
...s,
|
|
1410
|
-
error:
|
|
1417
|
+
error: error,
|
|
1411
1418
|
status: 'error',
|
|
1412
1419
|
isFetching: false,
|
|
1413
1420
|
updatedAt: Date.now()
|
|
1414
1421
|
}));
|
|
1422
|
+
console.log(this.getRouteMatch(match.id)?.status);
|
|
1415
1423
|
}
|
|
1416
|
-
}
|
|
1424
|
+
};
|
|
1425
|
+
const loadPromise = load();
|
|
1417
1426
|
this.setRouteMatch(match.id, s => ({
|
|
1418
1427
|
...s,
|
|
1419
1428
|
status: s.status !== 'success' ? 'pending' : s.status,
|
|
@@ -1837,13 +1846,18 @@
|
|
|
1837
1846
|
return this.state.matchesById[id];
|
|
1838
1847
|
};
|
|
1839
1848
|
setRouteMatch = (id, updater) => {
|
|
1840
|
-
this.__store.setState(prev =>
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
...prev.matchesById,
|
|
1844
|
-
[id]: updater(prev.matchesById[id])
|
|
1849
|
+
this.__store.setState(prev => {
|
|
1850
|
+
if (!prev.matchesById[id]) {
|
|
1851
|
+
console.warn(`No match found with id: ${id}`);
|
|
1845
1852
|
}
|
|
1846
|
-
|
|
1853
|
+
return {
|
|
1854
|
+
...prev,
|
|
1855
|
+
matchesById: {
|
|
1856
|
+
...prev.matchesById,
|
|
1857
|
+
[id]: updater(prev.matchesById[id])
|
|
1858
|
+
}
|
|
1859
|
+
};
|
|
1860
|
+
});
|
|
1847
1861
|
};
|
|
1848
1862
|
setRouteMatchData = (id, updater, opts) => {
|
|
1849
1863
|
const match = this.getRouteMatch(id);
|
|
@@ -1852,6 +1866,7 @@
|
|
|
1852
1866
|
const updatedAt = opts?.updatedAt ?? Date.now();
|
|
1853
1867
|
const preloadInvalidAt = updatedAt + (opts?.maxAge ?? route.options.preloadMaxAge ?? this.options.defaultPreloadMaxAge ?? 5000);
|
|
1854
1868
|
const invalidAt = updatedAt + (opts?.maxAge ?? route.options.maxAge ?? this.options.defaultMaxAge ?? Infinity);
|
|
1869
|
+
console.log('set success');
|
|
1855
1870
|
this.setRouteMatch(id, s => ({
|
|
1856
1871
|
...s,
|
|
1857
1872
|
error: undefined,
|