Created
January 26, 2023 07:22
-
-
Save JoueBien/3448895ca6435323486be84254ad4801 to your computer and use it in GitHub Desktop.
useIsSSR
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
// Libs | |
import { useEffect, useState } from "react"; | |
export default function useIsSSR() { | |
// Local State | |
const [isClient, setIsClient] = useState<boolean>(false); | |
const [isSSR, setIsSSR] = useState<boolean>(true); | |
// On Mount set where we are | |
useEffect(() => { | |
setIsClient(true); | |
setIsSSR(false); | |
}, []); | |
return { | |
isClient, | |
isSSR, | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment