mirror of
https://github.com/penxio/penx.git
synced 2026-01-12 23:18:09 -05:00
17 lines
343 B
TypeScript
17 lines
343 B
TypeScript
import React, { PropsWithChildren, useEffect, useState } from 'react'
|
|
|
|
export function ClientOnly({ children }: PropsWithChildren) {
|
|
// State / Props
|
|
const [hasMounted, setHasMounted] = useState(false)
|
|
|
|
// Hooks
|
|
useEffect(() => {
|
|
setHasMounted(true)
|
|
}, [])
|
|
|
|
// Render
|
|
if (!hasMounted) return null
|
|
|
|
return <>{children}</>
|
|
}
|