Link component outside main router context #1578
Unanswered
benjavicente
asked this question in
Q&A
Replies: 1 comment
-
This is just an observation having glanced over the internals of tanstack router in the last few days. The RouterProvider component internally just returns <RouterContextProvider router={router} {...rest}>
<Matches />
</RouterContextProvider> And in the Matches component, it wraps some suspense boundaries and some other jazz. But most importantly, it wraps everything in const InnerProvider = ({ children }) => {
const matchId = useRouterState({
select: (s) => {
return s.matches[0]?.id
},
})
return (
<matchContext.Provider value={matchId}>
{children}
</matchContext.Provider>
)
}
const MyProvider = ({ children ) => {
return (
<RouterContextProvider router={modalRouter}>
<InnerProvider>
{children}
</InnerProvider>
</RouterContextProvider>
)
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi! It is possible to use the link component in some way, outside the
<RouterProvider />
that matches the routes?I tried
and got
Invariant failed: Could not find the nearest match!
when theModalLinkFromOutside
is rendered.Why I am doing this? I want to build a static site in Astro with FULL client side navigation in a modal (don't ask the server needed HTML/JS on navigation in it). The router layer is only added to the modal, and links outside the modal should open it.
Beta Was this translation helpful? Give feedback.
All reactions