Last active
November 17, 2024 22:56
-
-
Save Soumyarian98/20a1ed73a648a9cdc9c3853f9044b2d5 to your computer and use it in GitHub Desktop.
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
| import { useState, useEffect } from 'react'; | |
| const useIsClient = (): boolean => { | |
| const [isClient, setIsClient] = useState<boolean>(false); | |
| useEffect(() => { | |
| // This code runs only on the client | |
| setIsClient(true); | |
| }, []); | |
| return isClient; | |
| }; | |
| export default useIsClient; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment