Skip to content

Commit b3f6e16

Browse files
committed
fix(reactant-share): fix router cachedHistory replace issue
1 parent 9da53c9 commit b3f6e16

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

packages/reactant-share/src/modules/router.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,15 @@ class ReactantRouter extends BaseReactantRouter {
152152
() => this.router,
153153
(router) => {
154154
if (
155-
router?.location.pathname !==
156-
this.cachedHistory[0]?.location?.pathname
155+
router &&
156+
router.location.pathname !==
157+
this.cachedHistory[0]?.location?.pathname
157158
) {
158-
this.cachedHistory.unshift(router!);
159+
if (router.action === 'REPLACE') {
160+
this.cachedHistory[0] = router;
161+
} else {
162+
this.cachedHistory.unshift(router!);
163+
}
159164
this.cachedHistory.length = this.maxHistoryLength; // Limit the length of the historical stack
160165
}
161166
}
@@ -273,7 +278,7 @@ class ReactantRouter extends BaseReactantRouter {
273278
}
274279

275280
get maxHistoryLength() {
276-
return this.options.maxHistoryLength ?? 10;
281+
return this.options.maxHistoryLength ?? 50;
277282
}
278283

279284
watchRehydratedRouting() {

0 commit comments

Comments
 (0)