Skip to content

Commit 0d8aa4f

Browse files
committed
fix(reactant-share): fix stopWatching for watchRehydratedRouting
1 parent f5b1eb4 commit 0d8aa4f

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

packages/reactant-share/src/router.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class ReactantRouter extends BaseReactantRouter {
5959
});
6060

6161
if (!this.portDetector.shared) {
62-
this.watchRehydratedRouting();
62+
const stopWatching = this.watchRehydratedRouting();
6363
watch(
6464
this,
6565
() => this.router,
@@ -68,6 +68,9 @@ class ReactantRouter extends BaseReactantRouter {
6868
// just update the current router to routers mapping by name
6969
this._setRouters(this.portDetector.name, this.router);
7070
}
71+
if (!this.enableCacheRouting) {
72+
stopWatching();
73+
}
7174
}
7275
);
7376
}
@@ -102,7 +105,7 @@ class ReactantRouter extends BaseReactantRouter {
102105
}
103106
});
104107
} else if (this.enableCacheRouting) {
105-
this.watchRehydratedRouting();
108+
return this.watchRehydratedRouting();
106109
}
107110
});
108111
this.portDetector.onClient((transport) => {
@@ -200,6 +203,7 @@ class ReactantRouter extends BaseReactantRouter {
200203
}
201204
}
202205
);
206+
return stopWatching;
203207
}
204208

205209
protected _changeRoutingOnSever(name: string, router: RouterState) {

0 commit comments

Comments
 (0)