Open
Conversation
ClarkXia
reviewed
Apr 8, 2024
|
|
||
| componentWillReceiveProps(nextProps: Readonly<AppRouterProps>, nextContext: any): void { | ||
| if (nextProps.apps !== this.props.apps) { | ||
| this.tryPrefetch(nextProps); |
Collaborator
There was a problem hiding this comment.
在 componentWillReceiveProps 阶段会存在多次执行的情况,需要增加额外机制判断 apps / url 信息是否已完成预加载
ClarkXia
reviewed
Apr 8, 2024
| basename?: string; | ||
| fetch?: Fetch; | ||
| prefetch?: Prefetch; | ||
| apps?: AppConfig; |
Collaborator
There was a problem hiding this comment.
不增加额外参数,直接以 children 上的信息进行判断是不是也可以
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
现象:配置 approuter prefetch 后,实际未预加载微应用 router 相关资源
原因定位:AppRouter 内部在 construct 时,解析 React.children,进行微应用的 prefetch,这要求在 AppRouter 在构建时就需要提供所有微应用的 child。
修复方式:修改 @ice/plugin-icestark 插件中,对 AppRouter 的渲染方式,传入 apps,在 AppRouter 中,判定 apps 变化,做 prefetch。
构造方法时 prefetch
https://github.com/ice-lab/icestark/blob/master/packages/icestark/src/AppRouter.tsx#L79
依赖 child

https://github.com/ice-lab/icestark/blob/master/packages/icestark/src/AppRouter.tsx#L121
插件渲染时机


https://github.com/alibaba/ice/blob/master/packages/plugin-icestark/src/runtime/framework.tsx#L48