Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

umi旧项目迁移到icestark出现 Unable to retrieve lifecycles #758

Open
guhan121 opened this issue Nov 4, 2024 · 2 comments
Open

umi旧项目迁移到icestark出现 Unable to retrieve lifecycles #758

guhan121 opened this issue Nov 4, 2024 · 2 comments

Comments

@guhan121
Copy link

guhan121 commented Nov 4, 2024

旧umi项目改造, 子应用的index.html和index.html内<script src="./umi.138702b9.js"></script>的umi.138702b9.js加载成功,
但是 <script src="./umi.138702b9.js"></script> 执行需要加载的其他css,js均不能加载。
image

@guhan121
Copy link
Author

guhan121 commented Nov 5, 2024

image 可以解决css加载问题

@guhan121 guhan121 changed the title umi旧项目迁移时css,js未能加上base路径 umi旧项目迁移到icestark求助 Nov 5, 2024
@guhan121
Copy link
Author

guhan121 commented Nov 5, 2024

子应用 "@ice/stark-app": "^1.5.0",

// src/app.tsx

console.log('------------------------------------------');
console.log(`--------------${isInIcestark()}----------------------`);
// 在 icestark 中修改渲染的节点
export function modifyClientRenderOpts(memo: any) {
  return {
    ...memo,
    rootElement: isInIcestark() ? getMountNode() : memo.rootElement,
  };
}

// 为 icestark 注册生命周期
export function render(oldRender: any) {
  if (isInIcestark()) {
    registerAppEnter(() => {
      oldRender();
    });
    registerAppLeave(() => {
      ReactDOM.unmountComponentAtNode(getMountNode());
    });
  } else {
    oldRender();
  }
}

使用旧方案注册生命周期函数
image
主应用加载后依然报
image

/src/.umi/core/plugin.ts 文件中看不到mount,unmount的key

const plugin = new Plugin({
  validKeys: ['modifyClientRenderOpts','patchRoutes','rootContainer','render','onRouteChange','__mfsu','getInitialState','initialStateConfig','request',],
});

export { plugin };

@guhan121 guhan121 changed the title umi旧项目迁移到icestark求助 umi旧项目迁移到icestark出现 Unable to retrieve lifecycles Nov 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant