remix-run / react-router

Declarative routing for React
https://reactrouter.com
MIT License
52.98k stars 10.29k forks source link

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

Closed redasalmi closed 1 week ago

redasalmi commented 2 weeks ago

What version of React Router are you using?

v7

Steps to Reproduce

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:
```js
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

river0g commented 1 week ago

Hi, @redasalmi The following PR corrected the document: https://github.com/remix-run/react-router/commit/6c7c5147c6e434d6d2350d1762ab8f4fb6287069

redasalmi commented 1 week ago

yep, it does fix it. I'll test it again once it's released and close this issue. Thanks for flagging this out @river0g :100: