Track HiveGrid Cloud planning reference

This commit is contained in:
david committed 2026-06-26 20:48:01 +02:00
1 parent b3d5ea6764
commit e341c5938a
5784 files changed
+1104929 -3

No files matched your search

@@ -0,0 +1,27 @@
import { useEffect, useState } from "react";
const useLocalStorage = <T>(key: string | undefined, initialValue: T): [T, (value: T) => void] => {
const [storedValue, setStoredValue] = useState(initialValue);
useEffect(() => {
if (key) {
// Retrieve from localStorage
const item = window.localStorage.getItem(key);
if (item) {
setStoredValue(JSON.parse(item));
}
}
}, [key]);
const setValue = (value: T) => {
// Save state
setStoredValue(value);
if (key) {
// Save to localStorage
window.localStorage.setItem(key, JSON.stringify(value));
}
};
return [storedValue, setValue];
};
export default useLocalStorage;