#Making `handle` dynamic-ish?

1 messages · Page 1 of 1 (latest)

bitter basin
#

Y'all got any idea about how to make the handle "dynamic"? I have a shared layout that renders tabs, each one of those tabs leads to a sub-route. I have a mechanism to detect that a sub-route wants to be in the tabs:

  const matches = useMatches();

  const tabs = matches.find((match) => {
    const handle = match.handle as NavigationItemForTabs | {};

    if (handle && "tabsAsRoutes" in handle) {
      return match;
    }
  });

  const tabsAsRoutes =
    tabs && (tabs?.handle as NavigationItemForTabs).tabsAsRoutes;

The problem? Well, my handle in the sub-routes is always defined upfront, such as this:

export const handle: NavigationItemForTabs = {
  tabsAsRoutes: [
    { title: "Tracks", route: "/user/tracks" },
    { title: "Achievements", route: "/user/achievements" },
  ],
};

When does handle "run" exactly? Can I do server-side functions on it? Does it run before loader, and can I then maybe get data from there?

shy sigil
#

handle is just an exported value you can access, it doesn't run at any time

#

you can put a function there if you want, and pass the loader data as an argument