Skip to content

Commit

Permalink
fix: create histroy when render root app
Browse files Browse the repository at this point in the history
  • Loading branch information
思忠 committed May 9, 2020
1 parent 88656e0 commit 48d8da0
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions packages/plugin-icestark/src/module.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,22 +63,26 @@ const module = ({ appConfig, addDOMRender, setRenderRouter, modifyRoutes }) => {
});
} else if (appType === 'framework') {
const { getApps, appRouter, Layout, AppRoute: CustomAppRoute, removeRoutesLayout } = (icestark || {}) as IIceStark;
const history = createHistory(type, basename);
if (removeRoutesLayout) {
modifyRoutes(removeRootLayout);
}
const RootApp = ({ routes }) => {
const [routerHistory] = useState(createHistory(type, basename));
const routerProps = {
type,
routes,
basename,
history: routerHistory,
};
return <IceRouter {...routerProps} />;
};

const frameworkRouter = (routes) => () => {
const [appPathname, setAppPathname] = useState('');
const [appEnter, setAppEnter] = useState({});
const [appLeave, setAppLeave] = useState({});

const [apps, setApps] = useState(null);
const routerProps = {
type,
routes,
basename,
history
};
const BasicLayout = Layout || DefaultLayout;
const RenderAppRoute = CustomAppRoute || AppRoute;

Expand Down Expand Up @@ -130,7 +134,7 @@ const module = ({ appConfig, addDOMRender, setRenderRouter, modifyRoutes }) => {
<RenderAppRoute
path="/"
render={() => {
return <IceRouter {...routerProps} />;
return <RootApp routes={routes} />;
}}
/>
)}
Expand Down

0 comments on commit 48d8da0

Please sign in to comment.