Skip to content

Commit

Permalink
fix: update route config when dataLoader is not defined (#6552)
Browse files Browse the repository at this point in the history
* fix: update route config when dataLoader is not defined

* chore: test case
  • Loading branch information
ClarkXia authored Sep 27, 2023
1 parent 244bb17 commit 4d256e3
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/tiny-hounds-hope.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@ice/runtime': patch
---

fix: update route config when dataLoader is not defined
4 changes: 3 additions & 1 deletion examples/hash-router/src/pages/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { Outlet } from 'ice';
import { Outlet, useConfig } from 'ice';

export default () => {
const config = useConfig();
return (
<div>
<h1>Layout</h1>
<h3>{config.title}</h3>
<Outlet />
</div>
);
Expand Down
8 changes: 6 additions & 2 deletions packages/runtime/src/routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,14 @@ export function createRouteLoader(options: RouteLoaderOptions): LoaderFunction {
}

if (!dataLoaderConfig) {
return () => {
return {
return async () => {
const loaderData = {
pageConfig: pageConfig ? pageConfig({}) : {},
};
if (import.meta.renderer === 'client') {
await updateRoutesConfig(loaderData);
}
return loaderData;
};
}

Expand Down

0 comments on commit 4d256e3

Please sign in to comment.