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
interface CombinedStatus<T> { | |
status: "IDLE" | "PENDING" | "SUCCESS" | "FAILURE"; | |
data: T | null; | |
} | |
function useApi<ApiResultType extends object, Payload>( | |
repoFunc: ( | |
payload: Payload | |
) => Promise<ApiResultType> | |
) { | |
const _repoFunc = useRef(repoFunc); |
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 } from "react"; | |
export function useLocalStorage<T>( | |
key: string, | |
initialValue: T | |
): [T, (value: T | ((val: T) => T)) => void] { | |
const [storedValue, setStoredValue] = useState<T>(() => { | |
try { | |
const item = window.localStorage.getItem(key); | |
return item ? JSON.parse(item) : initialValue; |
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
ㄴㄴ |
NewerOlder