Skip to content

fix: import Routes and Route in AdminDashboard (admin panel renders blank) - #84

Open
jsnapoli1 wants to merge 1 commit into
AJFrio:mainfrom
jsnapoli1:fix/admin-dashboard-missing-router-imports
Open

fix: import Routes and Route in AdminDashboard (admin panel renders blank)#84
jsnapoli1 wants to merge 1 commit into
AJFrio:mainfrom
jsnapoli1:fix/admin-dashboard-missing-router-imports

Conversation

@jsnapoli1

Copy link
Copy Markdown

Problem

The admin panel at /admin renders a white screen. The console shows:

Uncaught ReferenceError: Routes is not defined
    at index-<hash>.js:4314

src/pages/admin/AdminDashboard.jsx renders <Routes> and <Route> but imports only Navigate from react-router-dom. When AdminDashboard mounts, Routes is undefined, React throws, and the tree unmounts — leaving an empty #root.

The storefront is unaffected, because App.jsx imports both correctly. Only the admin route crashes.

Why the build doesn't catch it

Rollup leaves the unresolved identifiers as bare globals rather than failing, so the bundle is emitted successfully. It's visible in the output as an asymmetry — every real component is minified, but Routes and Route are not:

p.jsx(Routes,{children:p.jsxs(Route,{element:p.jsx(Jle,{...

npx eslint src/pages/admin/AdminDashboard.jsx also exits clean, since no-undef isn't flagging JSX component references under the current config.

Fix

-import { Navigate } from 'react-router-dom'
+import { Navigate, Routes, Route } from 'react-router-dom'

Verification

Built and deployed to a live Cloudflare Workers instance.

Before#root empty after the crash.

After#root contains the rendered admin login (verified via headless Chrome --dump-dom):

OpenShop Admin | Sign in to manage your store | Password | Sign In

The bundle's former crash site now reads p.jsx(GI,{...p.jsxs(Dr, — properly resolved and minified. Zero bare Routes/Route references remain.

Possible follow-up

Enabling react/jsx-no-undef (or no-undef for JSX identifiers) in the eslint config would catch this class of bug at lint time. Happy to open a separate PR if that's wanted.

https://claude.ai/code/session_015XLFFfHWNeazSuz6UcsQ4C

AdminDashboard renders <Routes> and <Route> but only imported Navigate
from react-router-dom, so the admin panel crashed on mount with
"Uncaught ReferenceError: Routes is not defined" and rendered a white
screen. The storefront was unaffected because App.jsx imports both.

The build does not catch this: Rollup leaves the unresolved identifiers
as bare globals, so the bundle is emitted successfully. It is visible in
the output as an asymmetry, where every real component is minified but
Routes and Route are not:

    p.jsx(Routes,{children:p.jsxs(Route,{element:p.jsx(Jle,{...

eslint also exits clean on the file, since no-undef is not enabled for
JSX component references in the current config.

Claude-Session: https://claude.ai/code/session_015XLFFfHWNeazSuz6UcsQ4C
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.

1 participant