Skip to content
This repository has been archived by the owner on Mar 7, 2024. It is now read-only.

Commit

Permalink
fix: 修复 cache router 无效问题 (#1416)
Browse files Browse the repository at this point in the history
close #1415

Co-authored-by: juvham <[email protected]>
Co-authored-by: Wei Zhu <[email protected]>
Co-authored-by: jhyi <[email protected]>
  • Loading branch information
4 people committed Dec 5, 2020
1 parent a6d9d3a commit 7d92597
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions packages/remax-web/src/createApp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,17 @@ export default function createApp(options: BootstrapOptions, history: History) {

const pluginDriver = new PluginDriver(plugins.map(plugin => plugin.default || plugin));
RuntimeOptions.apply({ pluginDriver });

const pageComponentsHoc = pages.map((page, i) => {
const pageComponent = async
? loadable<any>(() =>
(pageComponents[i]() as Promise<{ default: React.ComponentType }>).then(({ default: c }) =>
createPageConfig(c, page.route)
)
)
: createPageConfig(pageComponents[i]() as React.ComponentType, page.route);
return pageComponent;
});
return (
<Router history={history as any}>
<AppConfig>
Expand All @@ -26,13 +37,7 @@ export default function createApp(options: BootstrapOptions, history: History) {
return (
<CacheRoute key={page.route} className="remax-cached-router-wrapper" path={`/${page.route}`} exact={true}>
{(props: any) => {
const pageComponent = async
? loadable<any>(() =>
(pageComponents[i]() as Promise<{ default: React.ComponentType }>).then(({ default: c }) =>
createPageConfig(c, page.route)
)
)
: createPageConfig(pageComponents[i]() as React.ComponentType, page.route);
const pageComponent = pageComponentsHoc[i];
return React.createElement(pageComponent, {
...props,
pageConfig: {
Expand Down

1 comment on commit 7d92597

@vercel
Copy link

@vercel vercel bot commented on 7d92597 Dec 5, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.