T
TanStack2y ago
correct-apricot

If with Outlet

Was wondering if there is a better way to do this ? Or if this would be the way to do it rn. Thanks
function TestComponent() {
const linksQuery = useSuspenseQuery<PageLinksResponse>({ queryKey });
const matchRoute = useMatchRoute();

const match = matchRoute({ from: '/dashboard/test/' }) || matchRoute({ from: '/dashboard/test' });
return (
<>
{match && <LinksPage data={linksQuery.data} />}
<Outlet />
</>
);
}
function TestComponent() {
const linksQuery = useSuspenseQuery<PageLinksResponse>({ queryKey });
const matchRoute = useMatchRoute();

const match = matchRoute({ from: '/dashboard/test/' }) || matchRoute({ from: '/dashboard/test' });
return (
<>
{match && <LinksPage data={linksQuery.data} />}
<Outlet />
</>
);
}
2 Replies
xenial-black
xenial-black2y ago
what exactly are you concerned about?
correct-apricot
correct-apricotOP2y ago
Wasnt sure if this would be not a common practise, or why i have to match for both test and test/ thought the match would be "true" when its one or the other ?

Did you find this page helpful?