S
SolidJS

support

pass session via `<Outlet />`

TTrader1017/28/2023
Is it possible to pass session to outlet like this? It doesn't seem to work. I'm using solid-start alpha btw
export const { routeData, Page } = Sessionize(() => {
const session = useRouteData<typeof routeData>();
return (
<Show when={session()} keyed>
{s => <Outlet {...s} />}
</Show>
);
});

export default Page;
export const { routeData, Page } = Sessionize(() => {
const session = useRouteData<typeof routeData>();
return (
<Show when={session()} keyed>
{s => <Outlet {...s} />}
</Show>
);
});

export default Page;
ZZanoryt7/28/2023
Have you thought about putting the session inside a Context? Then you can access that context (assuming you wrap the Context Provider in the main app outside of the Outlet area) from anything.
TTrader1017/28/2023
route data is better because I believe when you update the session, it immediately reflects the changes on the page. Also tbh it's hard to maintain that context because you would need to know when oauth session ends so you query at an interval the api route and I think it's pretty ugly to make things work this way and solid-start indeed doesn't accept any params on outlet
ZZanoryt7/28/2023
This is where you would consider createEffect() to watch for changes to the session, update the related store in the context, and anything underneath (in the tree) will benefit from any changes to the store.

Looking for more? Join the community!

Want results from more Discord servers?
Add your server
Recommended Posts