namedStorage instead of useStorage

This commit is contained in:
djmil 2023-11-10 13:25:24 +01:00
parent 6427844da3
commit 7acad9b0f3
2 changed files with 4 additions and 4 deletions

View File

@ -1,9 +1,9 @@
import { useReducer } from 'react'; import { useReducer } from 'react';
import { useLocalStorage } from '../util/PersistentStorage'; import { namedLocalStorage } from '../util/PersistentStorage';
import { nextState } from '../util/StateHelper'; import { nextState } from '../util/StateHelper';
const Persistent = (() => { const Persistent = (() => {
const [getEnabled, setEnabled] = useLocalStorage('polling.enabled', true); const [getEnabled, setEnabled] = namedLocalStorage('polling.enabled', true);
return { return {
getEnabled, getEnabled,

View File

@ -1,4 +1,4 @@
export function useLocalStorage(name, initialValue) { export function namedLocalStorage(name, initialValue) {
const get = () => localStorage.getItem(name); const get = () => localStorage.getItem(name);
const del = () => localStorage.removeItem(name); const del = () => localStorage.removeItem(name);
@ -14,7 +14,7 @@ export function useLocalStorage(name, initialValue) {
return [get, set, del] return [get, set, del]
} }
export function useSessionStorage(name, initialValue) { export function namedSessionStorage(name, initialValue) {
const get = () => sessionStorage.getItem(name); const get = () => sessionStorage.getItem(name);
const del = () => sessionStorage.removeItem(name); const del = () => sessionStorage.removeItem(name);