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 { useRef } from 'react'; | |
import Countdown, { CountdownApi, CountdownRenderProps } from 'react-countdown'; | |
import { CountdownRenderPropsExtended, CustomCountdownProps } from '../types'; | |
export function useCustomCountdown({ time, renderer, customRenderer }: CustomCountdownProps) { | |
const countdownRef = useRef<Countdown>(null); | |
function calculateRemainingTime() { | |
const { days = 0, hours = 0, minutes = 0, seconds = 0 } = time; |
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, useMemo } from "react"; | |
type Props = { | |
reloadMode?: "never" | "always" | "onChange"; | |
initialParams?: Record<string, string | boolean | number>; | |
}; | |
export function useQueryParams< | |
T extends Record<string, string | boolean | number> | undefined | |
>({ reloadMode = "onChange", initialParams }: Props = {}) { |
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 useLocalStorage() { | |
function storeData<T>(key: string, data: T) { | |
try { | |
if (typeof window !== 'undefined') { | |
localStorage.setItem(key, JSON.stringify(data)); | |
return true; | |
} | |
return false; | |
} catch { |
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 React from "react"; | |
import { useMap } from "@/components/Map/hooks/useMap"; | |
import { Map, MarkerObject } from "@/components/Map"; | |
export function Example() { | |
const { settings, zoomOut, zoomIn, panTo, directions } = useMap({ | |
defaultCenter: { | |
lat: 0, | |
lng: 0, | |
}, |
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, useRef, useState } from "react"; | |
import { HOST, routes } from "./router"; | |
type UrlParam = Record<string, string | string[] | number | number[]>; | |
type Options<Payload, Response> = { | |
routeName: keyof typeof routes; | |
enabled?: boolean; | |
payload?: { | |
params?: UrlParam; |
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 { | |
useSearchParams as useNextSearchParams, | |
usePathname, | |
useRouter, | |
} from "next/navigation"; | |
export function useSearchParams<T extends Record<string, string>>() { | |
const searchParams = useNextSearchParams(); | |
const router = useRouter(); | |
const pathname = usePathname(); |