Skip to content

React Router v7 "Element type is invalid" for correctly default-exported route component #13336

@waelhabbal

Description

@waelhabbal

I'm using React Router as a...

framework

Reproduction

Set up a React Router v7 application with route modules.
Create a route module file (e.g., app/routes/welcome.tsx).
Ensure the primary route component (MyRoute in the example) is the default export of this file.
Navigate to the URL associated with this route in a browser.

System Info

System:
    OS: Windows 11 10.0.26100
    CPU: (12) x64 12th Gen Intel(R) Core(TM) i5-12450HX
    Memory: 3.10 GB / 15.71 GB
  Binaries:
    Node: 23.8.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.22 - ~\AppData\Local\pnpm\yarn.CMD
    npm: 10.9.2 - C:\Program Files\nodejs\npm.CMD
    pnpm: 10.5.2 - ~\AppData\Roaming\npm\pnpm.CMD
  Browsers:
    Edge: Chromium (134.0.3124.72)
    Internet Explorer: 11.0.26100.1882
  npmPackages:
    @react-router/dev: ^7.4.1 => 7.4.1
    @react-router/node: ^7.4.1 => 7.4.1
    @react-router/serve: ^7.4.1 => 7.4.1
    react-router: ^7.4.1 => 7.4.1
    vite: ^5.4.11 => 5.4.16

Used Package Manager

pnpm

Expected Behavior

The route component, being the default export, should render correctly.

Actual Behavior

The browser displays an error indicating: "Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports."

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions