This file contains 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
export function useDebounceEffect( | |
effect: React.EffectCallback, | |
delay = 500, | |
deps?: React.DependencyList | undefined, | |
) { | |
useEffect(() => { | |
const debounce = setTimeout(() => { | |
effect(); | |
}, delay); | |
return () => clearTimeout(debounce); |
This file contains 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
function useScript(id, src, options = {}) { | |
const { persist = true, onLoad } = options; | |
const [ready, setReady] = useState(false); | |
useEffect(() => { | |
const domScript = document.getElementById(id); | |
if (!domScript) { | |
const script = document.createElement('script'); |
This file contains 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 type { GetServerSidePropsContext, InferGetServerSidePropsType } from 'next'; | |
import Head from 'next/head'; | |
const Home = ({ host }: InferGetServerSidePropsType<typeof getServerSideProps>) => { | |
return ( | |
<> | |
<Head> | |
<title>Home Page</title> | |
</Head> |