Skip to content

Instantly share code, notes, and snippets.

@Soumyarian98
Last active November 17, 2024 22:56
Show Gist options
  • Select an option

  • Save Soumyarian98/20a1ed73a648a9cdc9c3853f9044b2d5 to your computer and use it in GitHub Desktop.

Select an option

Save Soumyarian98/20a1ed73a648a9cdc9c3853f9044b2d5 to your computer and use it in GitHub Desktop.
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