diff --git a/.changeset/ninety-tables-help.md b/.changeset/ninety-tables-help.md new file mode 100644 index 000000000000..7061149413b6 --- /dev/null +++ b/.changeset/ninety-tables-help.md @@ -0,0 +1,6 @@ +--- +'@modern-js/runtime': patch +--- + +fix: fix remixRouter not existed in conventional routes +fix: 修复 remixRouter 在约定式路由下不存在问题 diff --git a/packages/runtime/plugin-runtime/src/router/runtime/plugin.node.tsx b/packages/runtime/plugin-runtime/src/router/runtime/plugin.node.tsx index eebd8ba4255d..82cc0719bb98 100644 --- a/packages/runtime/plugin-runtime/src/router/runtime/plugin.node.tsx +++ b/packages/runtime/plugin-runtime/src/router/runtime/plugin.node.tsx @@ -162,11 +162,16 @@ export const routerPlugin = ({ pickContext: ({ context, pickedContext }, next) => { const { remixRouter } = context; + // remixRouter is not existed in conventional routes + if (!remixRouter) { + return next({ context, pickedContext }); + } + // only export partial common API from remix-router const router = { - navigate: remixRouter!.navigate, + navigate: remixRouter.navigate, get location() { - return remixRouter!.state.location; + return remixRouter.state.location; }, };