Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove router field in runtimeContext #6497

Merged
merged 2 commits into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading