Skip to content

Commit

Permalink
chore: remove router field in runtimeContext (#6497)
Browse files Browse the repository at this point in the history
  • Loading branch information
zllkjc authored Nov 6, 2024
1 parent 268d2a4 commit fe9264a
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 48 deletions.
5 changes: 1 addition & 4 deletions packages/runtime/plugin-runtime/src/core/context/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,14 @@ export const ServerRouterContext = createContext({} as any);

export interface TRuntimeContext extends Partial<BaseRuntimeContext> {
initialData?: Record<string, unknown>;
isBrowser: boolean;
context: TSSRContext;
/** @deprecated use context.request field instead */
request?: SSRServerContext['request'];
/** @deprecated use context.response field instead */
response?: SSRServerContext['response'];
// store type
store?: Store;
router?: {
navigate: Router['navigate'];
location: RouterState['location'];
};
[key: string]: any;
}

Expand Down
21 changes: 0 additions & 21 deletions packages/runtime/plugin-runtime/src/router/runtime/plugin.node.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -180,27 +180,6 @@ export const routerPlugin = (

return getRouteApp();
},
pickContext: pickedContext => {
const { remixRouter } = pickedContext;

// remixRouter is not existed in conventional routes
if (!remixRouter) {
return pickedContext;
}

// only export partial common API from remix-router
const router = {
navigate: remixRouter.navigate,
get location() {
return remixRouter.state.location;
},
};

return {
...pickedContext,
router,
};
},
};
},
};
Expand Down
23 changes: 0 additions & 23 deletions packages/runtime/plugin-runtime/src/router/runtime/plugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -194,29 +194,6 @@ export const routerPlugin = (

return getRouteApp();
},
pickContext: pickedContext => {
const { remixRouter } = pickedContext;

// two scenarios: 1. remixRouter is not existed in conventional routes;
// 2. useRuntimeContext can be called by users before hoc hooks execute
if (!remixRouter) {
return pickedContext;
}

// only export partial common API from remix-router
const router = {
...pickedContext.router,
navigate: remixRouter.navigate,
get location() {
return remixRouter.state.location;
},
};

return {
...pickedContext,
router,
};
},
};
},
};
Expand Down

0 comments on commit fe9264a

Please sign in to comment.