@remix-run/router 1.21.0 → 1.21.1-pre.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/CHANGELOG.md +7 -0
- package/dist/router.cjs.js +35 -17
- package/dist/router.cjs.js.map +1 -1
- package/dist/router.js +33 -17
- package/dist/router.js.map +1 -1
- package/dist/router.umd.js +35 -17
- package/dist/router.umd.js.map +1 -1
- package/dist/router.umd.min.js +2 -2
- package/dist/router.umd.min.js.map +1 -1
- package/package.json +1 -1
- package/router.ts +36 -16
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# `@remix-run/router`
|
|
2
2
|
|
|
3
|
+
## 1.21.1-pre.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- - Fix issue with fetcher data cleanup in the data layer on fetcher unmount ([#12674](https://github.com/remix-run/react-router/pull/12674))
|
|
8
|
+
- Fix behavior of manual fetcher keys when not opted into `future.v7_fetcherPersist`
|
|
9
|
+
|
|
3
10
|
## 1.21.0
|
|
4
11
|
|
|
5
12
|
### Minor Changes
|
package/dist/router.cjs.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @remix-run/router v1.21.0
|
|
2
|
+
* @remix-run/router v1.21.1-pre.0
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Remix Software Inc.
|
|
5
5
|
*
|
|
@@ -2041,6 +2041,14 @@ function createRouter(init) {
|
|
|
2041
2041
|
});
|
|
2042
2042
|
}
|
|
2043
2043
|
|
|
2044
|
+
// Remove any lingering deleted fetchers that have already been removed
|
|
2045
|
+
// from state.fetchers
|
|
2046
|
+
deletedFetchers.forEach(key => {
|
|
2047
|
+
if (!state.fetchers.has(key) && !fetchControllers.has(key)) {
|
|
2048
|
+
deletedFetchersKeys.push(key);
|
|
2049
|
+
}
|
|
2050
|
+
});
|
|
2051
|
+
|
|
2044
2052
|
// Iterate over a local copy so that if flushSync is used and we end up
|
|
2045
2053
|
// removing and adding a new subscriber due to the useCallback dependencies,
|
|
2046
2054
|
// we don't get ourselves into a loop calling the new subscriber immediately
|
|
@@ -2054,6 +2062,10 @@ function createRouter(init) {
|
|
|
2054
2062
|
if (future.v7_fetcherPersist) {
|
|
2055
2063
|
completedFetchers.forEach(key => state.fetchers.delete(key));
|
|
2056
2064
|
deletedFetchersKeys.forEach(key => deleteFetcher(key));
|
|
2065
|
+
} else {
|
|
2066
|
+
// We already called deleteFetcher() on these, can remove them from this
|
|
2067
|
+
// Set now that we've handed the keys off to the data layer
|
|
2068
|
+
deletedFetchersKeys.forEach(key => deletedFetchers.delete(key));
|
|
2057
2069
|
}
|
|
2058
2070
|
}
|
|
2059
2071
|
|
|
@@ -3312,13 +3324,11 @@ function createRouter(init) {
|
|
|
3312
3324
|
});
|
|
3313
3325
|
}
|
|
3314
3326
|
function getFetcher(key) {
|
|
3315
|
-
|
|
3316
|
-
|
|
3317
|
-
|
|
3318
|
-
|
|
3319
|
-
|
|
3320
|
-
deletedFetchers.delete(key);
|
|
3321
|
-
}
|
|
3327
|
+
activeFetchers.set(key, (activeFetchers.get(key) || 0) + 1);
|
|
3328
|
+
// If this fetcher was previously marked for deletion, unmark it since we
|
|
3329
|
+
// have a new instance
|
|
3330
|
+
if (deletedFetchers.has(key)) {
|
|
3331
|
+
deletedFetchers.delete(key);
|
|
3322
3332
|
}
|
|
3323
3333
|
return state.fetchers.get(key) || IDLE_FETCHER;
|
|
3324
3334
|
}
|
|
@@ -3333,21 +3343,29 @@ function createRouter(init) {
|
|
|
3333
3343
|
fetchLoadMatches.delete(key);
|
|
3334
3344
|
fetchReloadIds.delete(key);
|
|
3335
3345
|
fetchRedirectIds.delete(key);
|
|
3336
|
-
|
|
3346
|
+
|
|
3347
|
+
// If we opted into the flag we can clear this now since we're calling
|
|
3348
|
+
// deleteFetcher() at the end of updateState() and we've already handed the
|
|
3349
|
+
// deleted fetcher keys off to the data layer.
|
|
3350
|
+
// If not, we're eagerly calling deleteFetcher() and we need to keep this
|
|
3351
|
+
// Set populated until the next updateState call, and we'll clear
|
|
3352
|
+
// `deletedFetchers` then
|
|
3353
|
+
if (future.v7_fetcherPersist) {
|
|
3354
|
+
deletedFetchers.delete(key);
|
|
3355
|
+
}
|
|
3337
3356
|
cancelledFetcherLoads.delete(key);
|
|
3338
3357
|
state.fetchers.delete(key);
|
|
3339
3358
|
}
|
|
3340
3359
|
function deleteFetcherAndUpdateState(key) {
|
|
3341
|
-
|
|
3342
|
-
|
|
3343
|
-
|
|
3344
|
-
|
|
3345
|
-
|
|
3346
|
-
|
|
3347
|
-
activeFetchers.set(key, count);
|
|
3360
|
+
let count = (activeFetchers.get(key) || 0) - 1;
|
|
3361
|
+
if (count <= 0) {
|
|
3362
|
+
activeFetchers.delete(key);
|
|
3363
|
+
deletedFetchers.add(key);
|
|
3364
|
+
if (!future.v7_fetcherPersist) {
|
|
3365
|
+
deleteFetcher(key);
|
|
3348
3366
|
}
|
|
3349
3367
|
} else {
|
|
3350
|
-
|
|
3368
|
+
activeFetchers.set(key, count);
|
|
3351
3369
|
}
|
|
3352
3370
|
updateState({
|
|
3353
3371
|
fetchers: new Map(state.fetchers)
|