Files
coder/site/src/hooks/useLocalStorage.ts
T
Kira Pilot dca77ba487 feat: add workspaces banner for impending deletion (#7538)
* feat: add workspaces banner for impending deletion

* added storybook

* remove storybook - cannot add because of hook used in badge component
2023-05-16 07:01:22 -07:00

26 lines
605 B
TypeScript

interface UseLocalStorage {
saveLocal: (arg0: string, arg1: string) => void
getLocal: (arg0: string) => string | undefined
clearLocal: (arg0: string) => void
}
export const useLocalStorage = (): UseLocalStorage => {
return {
saveLocal,
getLocal,
clearLocal,
}
}
const saveLocal = (itemKey: string, itemValue: string): void => {
window.localStorage.setItem(itemKey, itemValue)
}
const getLocal = (itemKey: string): string | undefined => {
return localStorage.getItem(itemKey) ?? undefined
}
const clearLocal = (itemKey: string): void => {
localStorage.removeItem(itemKey)
}