Created
November 24, 2024 22:08
-
-
Save JacobWeisenburger/dfb82949f99326f7fa5dce9115d52037 to your computer and use it in GitHub Desktop.
Only render children on client
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use client' | |
import { useEffect, useState } from 'react' | |
// https://www.youtube.com/watch?v=KAjemAivU24 | |
export function NoSSR ( { children }: { children?: React.ReactNode } ) { | |
const [ isClient, setIsClient ] = useState( false ) | |
useEffect( () => { setIsClient( true ) }, [] ) | |
return isClient ? <>{children}</> : null | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment