File Based Routing confusion #14334
Replies: 1 comment
-
The In your case you have Then the rest of your routes start with So using your whole example:
This will defined these URLs:
See how the Related to the docs section you linked about using folders for organization, the file convention is flat based, that means you don't nest folder to nest routes. You use the file names following conventions like using So folders here are used to organize code for that specific route. This means that you can do:
And both files will be considered the same route, so instead of using the file name (first example) to know how the route will work you use you can use the folder name (second example). The second way allows you to add other files like maybe a component, a utility function, tests, assets like images or CSS files. etc. so you can end up with:
And only the All of that said, if you're not convinced on the convention, the |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi all,
I'm evaluating whether react router would be a good fit for my team. We enjoy using file based routing so we find that this feature is quite important to us to adopt it. However I'm struggling with the mental model of the routing behaviour and what I'm expecting to work is not.
I have the follow tree structure
The nested param routes don't seem to map to my expected routes. I'm expecting that we'd have
What actually happens
Now ideally I would've thought this nesting would work, but other than /contacts working everything else results in a 404.
How does the routing behaviour actually work? I've read these docs but I'm not sure how that shows how to handle nested file routing.
Beta Was this translation helpful? Give feedback.
All reactions