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 { | |
PropsWithChildren, | |
FC, | |
createContext, | |
useState, | |
useEffect, | |
} from "react"; | |
import Analytics, { AnalyticsInstance } from "analytics"; | |
import googleTagManager from "@analytics/google-tag-manager"; | |
import { useRouter } from "next/router"; |
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 { useEffect, useState } from "react"; | |
export function useScreenSize() { | |
// Local State | |
const [width, setWidth] = useState<number>(1200); | |
const [height, setHeight] = useState<number>(900); | |
// Update the height | |
function onScreenSizeChange(_event: Event) { | |
setWidth(window.innerWidth); |
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 { useEffect } from "react"; | |
export function useKeyUp(callback: (event: KeyboardEvent) => void) { | |
function onKeyPress(event: KeyboardEvent) { | |
callback(event); | |
} | |
// On Mount and callback change | |
useEffect(() => { | |
document.addEventListener("keyup", onKeyPress); |
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
// 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 |