diff --git a/packages/icestark/package.json b/packages/icestark/package.json index e87d4e28..2b9dd822 100644 --- a/packages/icestark/package.json +++ b/packages/icestark/package.json @@ -1,6 +1,6 @@ { "name": "@ice/stark", - "version": "2.7.5", + "version": "2.7.6", "description": "Icestark is a JavaScript library for multiple projects, Ice workbench solution.", "scripts": { "build": "rm -rf lib && tsc", diff --git a/packages/icestark/src/AppRouter.tsx b/packages/icestark/src/AppRouter.tsx index 6c7426b1..32a70b1e 100644 --- a/packages/icestark/src/AppRouter.tsx +++ b/packages/icestark/src/AppRouter.tsx @@ -35,6 +35,8 @@ export interface AppRouterProps { basename?: string; fetch?: Fetch; prefetch?: Prefetch; + apps?: AppConfig; + children?: React.ReactChildren; } interface AppRouterState { @@ -74,11 +76,7 @@ export default class AppRouter extends React.Component, nextContext: any): void { + if (nextProps.apps !== this.props.apps) { + this.tryPrefetch(nextProps); + } + } + + /** + * try to prefetch again + * @param props + */ + tryPrefetch(props: AppRouterProps): void { + const { fetch, prefetch: strategy, children } = props; + + if (strategy) { + this.prefetch(strategy, children, fetch); + } + } + /** * prefetch for resources. * no worry to excute `prefetch` many times, for all prefetched resources have been cached, and never request twice.