Is it possible to adjust the codegenerator to add default export or named export of the Route Name? #1812
-
It looks like good practice to use the when I create a new file in routes e.g. the autogenerated code is:
Now when I want to use that Route in my App, I end up with something like this:
To simplify things and allow for autoimport in my IDE I end up adding named exports in each Route file
which leads to this import: Is it possible to autogenerate that named export? Why isn't tanstack using a named export based on the filename in the first place? Am I possibly doing something wrong here, and utilizing the Route like that is not meant to be done? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 6 replies
-
It's easier to manipulate individual route files, such as updating paths, replacing As a recommendation, I would not import routes and use their fullPath property, because you can easily create circular dependencies that TS will not like. |
Beta Was this translation helpful? Give feedback.
you can use
Route.fullPath
in the component that is rendered by the route without causing circular dependencies.The problem of those circular dependencies can occur if you import e.g. RouteA in component ComponentB that is rendered on RouteB.
This is why we tend to recommend using string literals instead.
about that "having to pass the param again": you should not have to pass the param again, also if you use string literals.
Maybe there is a bug with relative routes though.
Can you please provide a minimal complete example by forking and adapting one of the existing examples on stackblitz?