webapp/src/components/_shared/ClientContainer.tsx

13 lines
400 B
TypeScript
Raw Normal View History

2022-11-14 10:02:08 +00:00
import type { JSX } from 'solid-js'
import { createSignal, onMount, Show } from 'solid-js'
// show children only on client side
// usage of isServer causing hydration errors
export const ClientContainer = (props: { children: JSX.Element }) => {
const [isMounted, setIsMounted] = createSignal(false)
onMount(() => setIsMounted(true))
return <Show when={isMounted()}>{props.children}</Show>
}