#`ClientOnly` fallback
6 messages · Page 1 of 1 (latest)
you can modify the implementation like this:
function ClientOnly(props: { children: JSX.Element, fallback?: JSX.Element }) {
const [mounted, setMounted] = createSignal(false)
onMount(() => setRender(true))
return <Show when={mounted()} fallback={props.fallback}>{props.children}</Show>
}
or use isHydrated from solid-primitives to do this anywhere:
return <>{isHydrated() ? <Client/> : <Fallback/>}</>
https://primitives.solidjs.community/package/lifecycle#ishydrated
you may want to combine clientonly with lazy and Suspense for code splitting too