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

[BUG] routes.ts is invalid because of missing route helper second string argument #12068

Open
redasalmi opened this issue Oct 4, 2024 · 0 comments
Labels

Comments

@redasalmi
Copy link

What version of React Router are you using?

v7

Steps to Reproduce

  • init a react-router v7 app
  • create a routes.ts file and copy this code from the documentation
import {
  type RouteConfig,
  route,
  index,
  layout,
} from "@react-router/dev/routes";

export const routes: RouteConfig = [
  index("./home.tsx"),
  route("about", "./about.tsx"),

  layout("./auth/layout.tsx", [
    route("login", "./auth/login.tsx"),
    route("register", "./auth/register.tsx"),
  ]),

  route("concerts", [
    index("./concerts/home.tsx"),
    route(":city", "./concerts/city.tsx"),
    route("trending", "./concerts/trending.tsx"),
  ]),
];
  • start the dev server

Expected Behavior

the dev server should start and it should render the routes defined in the routes.ts file

Actual Behavior

  • the dev server crashes and logs:
Route config in "routes.ts" is invalid.

Path: routes.1.file
Invalid type: Expected string but received Array

I see that in the route helper function definition that it expects a second string argument, by adding that it fixes the issue but it'll render the child routes under it as nested layouts.
this could be just a documentation issue but copying a lot of examples from the dev branch routing guide crashes the app https://reactrouter.com/dev/guides/start/routing

@redasalmi redasalmi added the bug label Oct 4, 2024
@redasalmi redasalmi changed the title [BUG] routes.ts is invalid because of missing route helper second file string argument [BUG] routes.ts is invalid because of missing route helper second string argument Oct 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant