webapp/src/components/_shared/ShowOnlyOnClient.tsx
Ilya Y 784bb435c3
Feature/lint (#317)
* prettier

---------

Co-authored-by: Igor Lobanov <igor.lobanov@onetwotrip.com>
2023-11-14 18:10:00 +03:00

14 lines
396 B
TypeScript

import type { JSX } from 'solid-js'
import { createSignal, onMount, Show } 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>
}