Duplicates
Latest version
Current behavior 😯
Recently I updated from an old solidjs version to the latest also the new router. And noticed that the clientOnly method which was experimental back than doesn't work when wrapping props.children. This is my code:
Helper:
import { clientOnly } from "@solidjs/start";
import { Component } from "solid-js";
export default function clientOnlyComponent<T>(component: Component<T>) {
return clientOnly(async () => ({ default: component }));
}
Usage:
import { useAuthSession } from "~/api";
import { Typography } from "@suid/material";
import TextMediaWrapper from "~/ui/TextMediaWrapper";
import { ParentProps, Show, Suspense } from "solid-js";
import clientOnlyComponent from "~/lib/util/clientOnlyComponent.ts";
export default function (props: ParentProps) {
const [authSession] = useAuthSession();
return (
<>
<Suspense>
<Show
when={authSession()}
fallback={
<TextMediaWrapper>
<Typography variant={"h4"} sx={{ textAlign: "center" }}>
Access Denied
</Typography>
</TextMediaWrapper>
}
>
{authSession()?.isExpired
? clientOnlyComponent(() => props.children)({})
: props.children}
</Show>
</Suspense>
</>
);
}
With the old <Outlet/> router, everything worked fine, but unfortunatey this implementation causes an endless loop on the browser after hydration which makes it unusable.
Expected behavior 🤔
A way to make props.children client only that doesn't cause and endless loop in the browser which completely freezes the tab.
Steps to reproduce 🕹
Steps:
- Copy my code
- Paste my code
- Fix syntax errors
- Run it ;)
You may experience it yourself in this neight little sample project. But don't be supprised that your tab freezes and you might have to force close it. I warned you 😉 https://stackblitz.com/~/github.com/BierDav/solid-start-ssr-bug
Context 🔦
I need the client only, because when the token that is stored in the request cookie is expired only the client can refresh it, and it wouldn't make sense to wait for all the unauthorized responses I would get when evaluating the ssr.
Your environment 🌎
System:
OS: Windows
Node: v21.7.1
Packages:
vinxi: ^0.3.10
solid-js: ^1.8.15
@solidjs/router: ^0.13.1
@solidjs/start: ^0.7.7
Duplicates
Latest version
Current behavior 😯
Recently I updated from an old solidjs version to the latest also the new router. And noticed that the
clientOnlymethod which was experimental back than doesn't work when wrappingprops.children. This is my code:Helper:
Usage:
With the old
<Outlet/>router, everything worked fine, but unfortunatey this implementation causes an endless loop on the browser after hydration which makes it unusable.Expected behavior 🤔
A way to make
props.childrenclient only that doesn't cause and endless loop in the browser which completely freezes the tab.Steps to reproduce 🕹
Steps:
You may experience it yourself in this neight little sample project. But don't be supprised that your tab freezes and you might have to force close it. I warned you 😉 https://stackblitz.com/~/github.com/BierDav/solid-start-ssr-bug
Context 🔦
I need the client only, because when the token that is stored in the request cookie is expired only the client can refresh it, and it wouldn't make sense to wait for all the unauthorized responses I would get when evaluating the ssr.
Your environment 🌎