diff --git a/.changeset/slimy-chairs-perform.md b/.changeset/slimy-chairs-perform.md new file mode 100644 index 00000000..8b120385 --- /dev/null +++ b/.changeset/slimy-chairs-perform.md @@ -0,0 +1,5 @@ +--- +'@alita/plugins': patch +--- + +fix: useEffets error diff --git a/packages/plugins/templates/mobile-layout/layout.tpl b/packages/plugins/templates/mobile-layout/layout.tpl index 822fe9f0..40645d8e 100644 --- a/packages/plugins/templates/mobile-layout/layout.tpl +++ b/packages/plugins/templates/mobile-layout/layout.tpl @@ -448,10 +448,12 @@ const BasicLayout: React.FC = (props) => { prevPathName = location.pathname; }, 10); }, [location.pathname]); - layoutEmitter?.useSubscription?.((e) => { - setPageNavBar(getPageNavBar()); - setTabBarList(getTabBarList()); - }); + useEffect(()=>{ + layoutEmitter?.useSubscription?.((e) => { + setPageNavBar(getPageNavBar()); + setTabBarList(getTabBarList()); + }); + },[]); let element = useOutlet(); {{#hasKeepAlive}} element = useKeepOutlets(); diff --git a/packages/plugins/templates/mobile-layout/layout5.tpl b/packages/plugins/templates/mobile-layout/layout5.tpl index ec91f2b5..3a9b66e7 100644 --- a/packages/plugins/templates/mobile-layout/layout5.tpl +++ b/packages/plugins/templates/mobile-layout/layout5.tpl @@ -434,10 +434,12 @@ const BasicLayout: React.FC = (props) => { prevPathName = location.pathname; }, 10); }, [location.pathname]); - layoutEmitter?.useSubscription?.((e) => { - setPageNavBar(getPageNavBar()); - setTabBarList(getTabBarList()); - }); + useEffect(()=>{ + layoutEmitter?.useSubscription?.((e) => { + setPageNavBar(getPageNavBar()); + setTabBarList(getTabBarList()); + }); + },[]); let element = useOutlet(); {{#hasKeepAlive}} element = useKeepOutlets();