mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-02-28 12:50:38 +00:00
fix: router rerender
This commit is contained in:
parent
9baba75ca1
commit
d886abc48d
@ -130,27 +130,27 @@
|
||||
},
|
||||
{
|
||||
"prototypeViewsUrl": null,
|
||||
"packageName": "@ali/vc-deep-mobile-yidaplus",
|
||||
"version": "1.0.4",
|
||||
"prototypeConfigsUrl": [
|
||||
"https://g.alicdn.com/legao-comp/web_bundle_0724/@ali/vc-deep-mobile-yidaplus/1.0.4/proto.23e380d.css",
|
||||
"https://g.alicdn.com/legao-comp/web_bundle_0724/@ali/vc-deep-mobile-yidaplus/1.0.4/proto.4d55c72.js"
|
||||
],
|
||||
"prototypeUrls": {
|
||||
"default": [
|
||||
"https://g.alicdn.com/legao-comp/web_bundle_0724/@ali/vc-deep-mobile/2.0.1-beta.25/proto.2f23cdf.css",
|
||||
"https://g.alicdn.com/legao-comp/web_bundle_0724/@ali/vc-deep-mobile/2.0.1-beta.25/proto.9a739a7.js"
|
||||
"https://g.alicdn.com/legao-comp/web_bundle_0724/@ali/vc-deep-mobile-yidaplus/1.0.4/proto.23e380d.css",
|
||||
"https://g.alicdn.com/legao-comp/web_bundle_0724/@ali/vc-deep-mobile-yidaplus/1.0.4/proto.4d55c72.js"
|
||||
]
|
||||
},
|
||||
"prototypeConfigsUrl": [
|
||||
"https://g.alicdn.com/legao-comp/web_bundle_0724/@ali/vc-deep-mobile/2.0.1-beta.25/proto.2f23cdf.css",
|
||||
"https://g.alicdn.com/legao-comp/web_bundle_0724/@ali/vc-deep-mobile/2.0.1-beta.25/proto.9a739a7.js"
|
||||
"library": "AliVcDeepMobileYidaplus",
|
||||
"urls": [
|
||||
"https://g.alicdn.com/legao-comp/web_bundle_0724/@ali/vc-deep-mobile-yidaplus/1.0.4/view.574f830.css",
|
||||
"https://g.alicdn.com/legao-comp/web_bundle_0724/@ali/vc-deep-mobile-yidaplus/1.0.4/view.fe356f3.js",
|
||||
"https://g.alicdn.com/legao-comp/web_bundle_0724/@ali/vc-deep-mobile-yidaplus/1.0.4/view.mobile.574f830.css",
|
||||
"https://g.alicdn.com/legao-comp/web_bundle_0724/@ali/vc-deep-mobile-yidaplus/1.0.4/view.mobile.f993078.js"
|
||||
],
|
||||
"alias": "",
|
||||
"urls": [
|
||||
"https://g.alicdn.com/legao-comp/web_bundle_0724/@ali/vc-deep-mobile/2.0.1-beta.25/view.d6d0d1f.css",
|
||||
"https://g.alicdn.com/legao-comp/web_bundle_0724/@ali/vc-deep-mobile/2.0.1-beta.25/view.14bb8e8.js",
|
||||
"https://g.alicdn.com/legao-comp/web_bundle_0724/@ali/vc-deep-mobile/2.0.1-beta.25/view.mobile. d6d0d1f.css",
|
||||
"https://g.alicdn.com/legao-comp/web_bundle_0724/@ali/vc-deep-mobile/2.0.1-beta.25/view.mobile.fe36565.js"
|
||||
],
|
||||
"library": "AliVcDeepMobile",
|
||||
"components": null,
|
||||
"packageName": "@ali/vc-deep-mobile",
|
||||
"version": "2.0.1-beta.25"
|
||||
"components": null
|
||||
},
|
||||
{
|
||||
"prototypeViewsUrl": null,
|
||||
|
||||
@ -208,6 +208,8 @@ function getInitialComponent(routerConfig) {
|
||||
return InitialComponent;
|
||||
}
|
||||
|
||||
let unlisten = null;
|
||||
let handleId = null;
|
||||
export function useRouter(routerConfig) {
|
||||
const [component, setComponent] = useState(getInitialComponent(routerConfig));
|
||||
|
||||
@ -218,29 +220,41 @@ export function useRouter(routerConfig) {
|
||||
}
|
||||
|
||||
useLayoutEffect(() => {
|
||||
if (_initialized) return;
|
||||
_initialized = true;
|
||||
if (unlisten) {
|
||||
unlisten();
|
||||
unlisten = null;
|
||||
}
|
||||
|
||||
if (handleId) {
|
||||
router.removeHandle(handleId);
|
||||
handleId = null;
|
||||
}
|
||||
|
||||
const history = _routerConfig.history;
|
||||
const routes = _routerConfig.routes;
|
||||
|
||||
router.root = Array.isArray(routes) ? { routes } : routes;
|
||||
|
||||
const handleId = router.addHandle((component) => {
|
||||
handleId = router.addHandle((component) => {
|
||||
setComponent(component);
|
||||
});
|
||||
|
||||
// Init path match
|
||||
if (!_routerConfig.InitialComponent) {
|
||||
if (_initialized || !_routerConfig.InitialComponent) {
|
||||
matchLocation(history.location);
|
||||
}
|
||||
|
||||
const unlisten = history.listen(({ location }) => {
|
||||
unlisten = history.listen(({ location }) => {
|
||||
matchLocation(location);
|
||||
});
|
||||
|
||||
_initialized = true;
|
||||
|
||||
return () => {
|
||||
router.removeHandle(handleId);
|
||||
handleId = null;
|
||||
unlisten();
|
||||
unlisten = null;
|
||||
};
|
||||
}, []);
|
||||
|
||||
|
||||
@ -237,7 +237,7 @@ export class SimulatorRendererContainer implements BuiltinSimulatorRenderer {
|
||||
constructor() {
|
||||
this.dispose = host.connect(this, () => {
|
||||
// sync layout config
|
||||
debugger;
|
||||
// debugger;
|
||||
this._layout = host.project.get('config').layout;
|
||||
|
||||
// todo: split with others, not all should recompute
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user