Use explicit params on loader function
I have a pathless route of
"/_layoutMain"
which is basically my layout.
Now I also have a "/channels/$guildId"
route.
But In the loader of "/_layoutMain"
I need to get the "$guildId"
of "/channels"
But the loader param object is now type of Record<never, string>
So I can't convince it that there is indeed a param here.
1 Reply
other-emerald•16mo ago
afaik, this is not possible. the loader of
/_layoutMain
can also run on pages that have no $guildId
, for example, when you have this setup:
now the loader of the layout will run for /foo
, but there is no $guildId
param. Best bet is to to a type assertion and then handle cases where the id exists and where it doesn't. The better fix is to use the loader of something that knows that the guildId
really exists