SolidJSS
SolidJSโ€ข2y agoโ€ข
3 replies
Lo | Building Dromo

Context providers inside <Routes> don't provide context values to routed content - Issue #273

This works:
<FooProvider>
  <Routes>
    <Route path=... component=... /> // the elements have access to context values
  </Routes>
</FooProvider>


This doesn't:
<Routes>
  <FooProvider>
    <Route path=... component=... /> // the elements don't have access to context values
  </FooProvider>
</Routes>


The solution that Ryan had provided here worked with solid-router 0.9.x but now with version 0.10.x it no longer work since <Outlet /> component and the element attribute no longer exist.

<Routes>
<AuthRoutes />
<FinanceRoutes />
<CalendarRoutes />
</Routes>

function AuthRoutes = () => {
return <Route path="" element={<I18nProvider namespaces={['auth']}><Outlet /></I18nProvider>}>
<Route path=... element=... />
<Route path=... element=... />
<Route path=... element=... />
</Route>
}

Does anyone know what the new solution is?
GitHub
Describe the bug This works: <FooProvider> <Routes> <Route path=... element=... /> // the elements have access to context values </Routes> </FooProvider> This doesn...
Context providers inside `` don't provide context values to routed ...
Was this page helpful?