T
TanStack•8mo ago
adverse-sapphire

staticData on a lazy route

Hi, I want to make a breadcrumb component using useMatches and staticData on my routes. Everything is ok until I want to use lazy route with createLazyFileRoute which doesn't allow staticData to be passed. I would like to know if there's an alternative to using staticData to achieve what I want to do, or if I need to stay on non lazy routes.
4 Replies
national-gold
national-gold•8mo ago
if you want to use staticData, you need to create an additional createFileRoute for the same path, so foo.tsx and foo.lazy.tsx however, I would just enable autoCodeSplitting and don't use manual lazy routes
adverse-sapphire
adverse-sapphireOP•8mo ago
Oh so I can createFileRoute and use autoCodeSplitting?
national-gold
national-gold•8mo ago
yes
adverse-sapphire
adverse-sapphireOP•8mo ago
Thank you for the answer 🙂

Did you find this page helpful?