webapp/src/components/_shared/ShowOnlyOnClient.tsx

14 lines
396 B
TypeScript
Raw Normal View History

import type { JSX } from 'solid-js'
2024-02-04 11:25:21 +00:00
import { Show, createSignal, onMount } from 'solid-js'
const [isClient, setIsClient] = createSignal(false)
// show children only on client side
// usage of isServer causing hydration errors
export const ShowOnlyOnClient = (props: { children: JSX.Element }) => {
onMount(() => setIsClient(true))
return <Show when={isClient()}>{props.children}</Show>
}