Skip to content

Comments

refactor: remove all instances of react-router-dom#1410

Open
paanSinghCoder wants to merge 3 commits intomainfrom
fix/page-load-errors
Open

refactor: remove all instances of react-router-dom#1410
paanSinghCoder wants to merge 3 commits intomainfrom
fix/page-load-errors

Conversation

@paanSinghCoder
Copy link
Contributor

Summary

Remove all instances of react-router-dom to make sdk truly router agnostic.

Changes

Technical Details

Test Plan

  • Manual testing completed
  • Build and type checking passes

@vercel
Copy link

vercel bot commented Feb 23, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
frontier Ready Ready Preview, Comment Feb 23, 2026 0:45am

@paanSinghCoder paanSinghCoder requested a review from rsbh February 23, 2026 12:32
@paanSinghCoder paanSinghCoder self-assigned this Feb 23, 2026
@coderabbitai
Copy link

coderabbitai bot commented Feb 23, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between dfe9421 and 46b5626.

⛔ Files ignored due to path filters (1)
  • web/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (1)
  • web/sdk/admin/views/preferences/columns.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • web/sdk/admin/views/preferences/columns.tsx

📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Improved navigation experience across admin pages for organizations, plans, preferences, and users.
  • Refactor

    • Refactored navigation system to use callback-based patterns for better component flexibility.
    • Updated list view components with enhanced interactivity across admin panels.
    • Removed router dependency from SDK package to decouple component architecture.

Walkthrough

This PR removes direct react-router-dom coupling from admin SDK views and pages by replacing Link/NavLink/useNavigate usage with optional callback props (onNavigateToOrg, onSelectPlan, onSelectPreference, onNavigate, onNavigateToUser). Pages supply navigation handlers; react-router-dom was removed from the SDK peerDependencies.

Changes

Cohort / File(s) Summary
Admin Pages
web/apps/admin/src/pages/admins/AdminsPage.tsx, web/apps/admin/src/pages/plans/PlansPage.tsx, web/apps/admin/src/pages/preferences/PreferencesPage.tsx, web/apps/admin/src/pages/users/UsersPage.tsx
Pages now use react-router hooks and pass navigation callbacks/props (onNavigateToOrg, onSelectPlan, onSelectPreference, currentPath/onNavigate) into view components.
Admins View
web/sdk/admin/views/admins/index.tsx, web/sdk/admin/views/admins/columns.tsx
Added AdminsViewProps with optional onNavigateToOrg; getColumns accepts options and Organization cell uses clickable Text invoking onNavigateToOrg instead of Link.
Plans View
web/sdk/admin/views/plans/index.tsx, web/sdk/admin/views/plans/columns.tsx
Added onSelectPlan prop to PlansViewProps; getColumns accepts options and ID column uses Text with onSelectPlan callback instead of Link.
Preferences View
web/sdk/admin/views/preferences/PreferencesView.tsx, web/sdk/admin/views/preferences/columns.tsx, web/sdk/admin/views/preferences/index.tsx
Added onSelectPreference prop; getColumns accepts options and Action/Edit uses clickable Text invoking onSelectPreference instead of Link.
Users View - Main & List
web/sdk/admin/views/users/UsersView.tsx, web/sdk/admin/views/users/list/columns.tsx, web/sdk/admin/views/users/list/list.tsx
UsersView gained currentPath and onNavigate props; list columns accept onNavigateToUser and render clickable user cell invoking callback instead of Link; list passes through onNavigateToUser.
Users View - Details & Layout
web/sdk/admin/views/users/details/user-details.tsx, web/sdk/admin/views/users/details/layout/layout.tsx, web/sdk/admin/views/users/details/layout/navbar.tsx
Threaded currentPath and onNavigate through UserDetails components; navbar replaced NavLink usage with Chip items using currentPath to determine active state and onNavigate for clicks.
Webhooks Views
web/sdk/admin/views/webhooks/webhooks/create/index.tsx, web/sdk/admin/views/webhooks/webhooks/header.tsx, web/sdk/admin/views/webhooks/webhooks/update/index.tsx
Removed useNavigate usage and fallback navigation; handlers now rely solely on provided callbacks (onOpenCreate/onCloseProp) and no longer navigate by default.
SDK package config
web/sdk/package.json
Removed react-router-dom from peerDependencies and peerDependenciesMeta, decoupling SDK from direct router dependency.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

Suggested reviewers

  • rsbh
  • rohanchkrabrty
  • rohilsurana

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coveralls
Copy link

coveralls commented Feb 23, 2026

Pull Request Test Coverage Report for Build 22306651313

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 39.848%

Totals Coverage Status
Change from base Build 22304373962: 0.0%
Covered Lines: 13595
Relevant Lines: 34117

💛 - Coveralls

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 6

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
web/sdk/package.json (1)

109-109: ⚠️ Potential issue | 🟠 Major

@tanstack/react-router remains deeply coupled throughout the SDK — contradicts the "router-agnostic" goal.

The SDK source imports from @tanstack/react-router in 50+ files across the organization, billing, teams, api-keys, sessions, profiles, projects, plans, domains, and members components. Hooks like useNavigate, useParams, useRouterState, useRouteContext, and components like Outlet and Link are used directly in the SDK code.

Removing react-router-dom from peerDependencies while keeping @tanstack/react-router in dependencies does not achieve router agnosticity—it simply couples the SDK to a different router. To be truly router-agnostic, the SDK should accept router-agnostic abstractions from consumers or provide a plugin system instead of hard-coupling to a specific router implementation.

🧹 Nitpick comments (8)
web/sdk/admin/views/webhooks/webhooks/update/index.tsx (1)

49-51: Unnecessary useCallback indirection

The memoized onClose only wraps onCloseProp?.() with no additional logic. The extra useCallback adds complexity without benefit.

♻️ Simplified close handler (assumes `onClose` is made required per above)
-  const onClose = useCallback(() => {
-    onCloseProp?.();
-  }, [onCloseProp]);

Remove the wrapper entirely and use onClose prop directly at the two call sites (line 84 and line 119).

web/sdk/admin/views/webhooks/webhooks/header.tsx (1)

17-18: handleCreate is a redundant wrapper — can pass onOpenCreate directly.

♻️ Proposed simplification
-export const WebhooksHeader = ({ header = pageHeader, onOpenCreate }: WebhooksHeaderProps) => {
-  const handleCreate = () => onOpenCreate?.();
-
-  return (
+export const WebhooksHeader = ({ header = pageHeader, onOpenCreate }: WebhooksHeaderProps) => {
+  return (
     <PageHeader ...>
       ...
-      <Button ... onClick={handleCreate}>
+      <Button ... onClick={onOpenCreate}>
web/sdk/admin/views/admins/index.tsx (1)

38-38: Memoize columns to avoid recreating column definitions on every render.

getColumns({ onNavigateToOrg }) is called at the top level of the render function. When AdminsPage passes an inline arrow for onNavigateToOrg (which it currently does), new column objects are produced on every render, which can cause DataTable to recalculate internals unnecessarily.

♻️ Proposed fix
+import { useMemo } from "react";
 ...
-  const columns = getColumns({ onNavigateToOrg });
+  const columns = useMemo(() => getColumns({ onNavigateToOrg }), [onNavigateToOrg]);
web/apps/admin/src/pages/admins/AdminsPage.tsx (1)

4-11: Inline arrow creates a new callback reference on every render; use useCallback.

onNavigateToOrg is a new function on every render, causing AdminsView (and ultimately getColumns) to re-execute each time AdminsPage re-renders. The same pattern applies to onSelectPlan in PlansPage.tsx — both should be stabilized. The explicit (orgId: string) type annotation is also redundant since TypeScript can infer it from AdminsViewProps.

♻️ Proposed fix
+import { useCallback } from "react";
 import { AdminsView } from "@raystack/frontier/admin";
 import { useNavigate } from "react-router-dom";
 
 export function AdminsPage() {
   const navigate = useNavigate();
+  const handleNavigateToOrg = useCallback(
+    (orgId: string) => navigate(`/organizations/${orgId}`),
+    [navigate]
+  );
 
   return (
-    <AdminsView
-      onNavigateToOrg={(orgId: string) => navigate(`/organizations/${orgId}`)}
-    />
+    <AdminsView onNavigateToOrg={handleNavigateToOrg} />
   );
 }
web/apps/admin/src/pages/plans/PlansPage.tsx (1)

8-14: Same inline-arrow render concern as AdminsPage.tsx.

onSelectPlan is recreated on each render. Consider wrapping it with useCallback for the same reasons noted in AdminsPage.tsx.

web/apps/admin/src/pages/preferences/PreferencesPage.tsx (1)

12-12: Redundant explicit type annotation on callback parameter.

TypeScript infers prefName's type from PreferencesViewProps.onSelectPreference?: (name: string) => void, so the inline annotation is unnecessary.

♻️ Suggested simplification
-      onSelectPreference={(prefName: string) => navigate(`/preferences/${prefName}`)}
+      onSelectPreference={(prefName) => navigate(`/preferences/${prefName}`)}
web/sdk/admin/views/users/details/layout/navbar.tsx (1)

34-53: Breadcrumb href props are still hard-coded, leaving navigation partially router-coupled.

The Breadcrumb.Item elements (lines 35 and 42) use raw href attributes that render as native <a> tags. In a SPA these cause full-page navigations, bypassing the new onNavigate callback pattern added by this PR. To complete the router-agnostic refactor, consider accepting breadcrumb navigation callbacks (e.g., onNavigateToUsers / onNavigateToUser) analogous to the onNavigate pattern already introduced here.

web/sdk/admin/views/plans/columns.tsx (1)

16-26: cursor: "pointer" is unconditional — misleading when onSelectPlan is absent.

When onSelectPlan is not provided, the ID cell still renders with a pointer cursor but the click is a no-op, which implies interactivity that doesn't exist.

🎨 Proposed fix
-          <Text
-            style={{ cursor: "pointer" }}
-            onClick={() => onSelectPlan?.(id)}
-          >
+          <Text
+            role={onSelectPlan ? "button" : undefined}
+            tabIndex={onSelectPlan ? 0 : undefined}
+            style={{ cursor: onSelectPlan ? "pointer" : "default" }}
+            onClick={() => onSelectPlan?.(id)}
+            onKeyDown={(e) =>
+              onSelectPlan && (e.key === "Enter" || e.key === " ") && onSelectPlan(id)
+            }
+          >

Note: the keyboard-accessibility gap (missing role="button" / tabIndex) mentioned in web/sdk/admin/views/preferences/columns.tsx applies identically here.


ℹ️ Review info

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 880cd5e and dfe9421.

📒 Files selected for processing (21)
  • web/apps/admin/src/pages/admins/AdminsPage.tsx
  • web/apps/admin/src/pages/plans/PlansPage.tsx
  • web/apps/admin/src/pages/preferences/PreferencesPage.tsx
  • web/apps/admin/src/pages/users/UsersPage.tsx
  • web/sdk/admin/views/admins/columns.tsx
  • web/sdk/admin/views/admins/index.tsx
  • web/sdk/admin/views/plans/columns.tsx
  • web/sdk/admin/views/plans/index.tsx
  • web/sdk/admin/views/preferences/PreferencesView.tsx
  • web/sdk/admin/views/preferences/columns.tsx
  • web/sdk/admin/views/preferences/index.tsx
  • web/sdk/admin/views/users/UsersView.tsx
  • web/sdk/admin/views/users/details/layout/layout.tsx
  • web/sdk/admin/views/users/details/layout/navbar.tsx
  • web/sdk/admin/views/users/details/user-details.tsx
  • web/sdk/admin/views/users/list/columns.tsx
  • web/sdk/admin/views/users/list/list.tsx
  • web/sdk/admin/views/webhooks/webhooks/create/index.tsx
  • web/sdk/admin/views/webhooks/webhooks/header.tsx
  • web/sdk/admin/views/webhooks/webhooks/update/index.tsx
  • web/sdk/package.json

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants