mirror of
https://github.com/coder/coder.git
synced 2026-11-18 21:20:37 +08:00
* feat: add workspaces banner for impending deletion * added storybook * remove storybook - cannot add because of hook used in badge component
26 lines
605 B
TypeScript
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)
|
|
}
|