Skip to content

Commit

Permalink
fix: single route mismatch warning for development (#6870)
Browse files Browse the repository at this point in the history
  • Loading branch information
ClarkXia authored May 7, 2024
1 parent a805fa9 commit e78c7d2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/red-ducks-look.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@ice/runtime': patch
---

fix: single route mismatch warning for development
8 changes: 6 additions & 2 deletions packages/runtime/src/singleRouter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,10 @@ export const matchRoutes = (
for (let i = 0; matches == null && i < branches.length; i++) {
matches = matchRouteBranch(branches[i], stripedPathname);
}
if (!matches) {
console.warn('Single route manifest: ', routes);
console.warn(`Basename "${basename}" is not match with pathname "${pathname}"`);
}
return matches;
};

Expand Down Expand Up @@ -316,13 +320,13 @@ export const getSingleRoute = async (
let loaders = [];
let loaderIds = [];
const components = matchedRoutes.map(({ route }) => {
const { loader } = routeModules[route.id];
const { loader, Component } = routeModules?.[route.id] || {};
if (loader) {
loaders.push(loader());
loaderIds.push(route.id);
}
return {
Component: routeModules[route.id].Component || route.Component,
Component: Component || route.Component,
isDataRoute: !!loader,
id: route.id,
};
Expand Down

0 comments on commit e78c7d2

Please sign in to comment.