T
TanStack2y ago
metropolitan-bronze

Circular import

Maybe I'm missing something, but the dependency between a route and a component seems to force the two the be in the same file. I would like to split TakeHomeDetail and takeHomeDetailsRoute to separate files. However the route is used in the useParams call in the component and the component is used directly in the route which would cause a circular import. Does anyone know of a solution for this?
No description
2 Replies
fair-rose
fair-rose2y ago
you can use useParams with the from string of the route, then there is no dependency why do you want to split into separate files?
metropolitan-bronze
metropolitan-bronzeOP2y ago
Thanks! Is there any way to maintain the type safety that using the route directly provides? I'm trying to prevent this eslint rule warning which I think originates from a bug in the lint rule. The lint rule is react-refresh/only-export-components. @Manuel Schiller Apologies, it's already providing the type safety! Thank you for the solution 👏

Did you find this page helpful?