flowbite-react
Version:
Official React components built for Flowbite and Tailwind CSS
19 lines (16 loc) • 488 B
JavaScript
'use client';
import { useEffect } from 'react';
function useWatchLocalStorageValue({
key: watchKey,
onChange
}) {
function handleStorageChange({ key, newValue }) {
if (key === watchKey) onChange(newValue);
}
useEffect(() => {
window.addEventListener("storage", handleStorageChange);
return () => window.removeEventListener("storage", handleStorageChange);
}, []);
}
export { useWatchLocalStorageValue };
//# sourceMappingURL=use-watch-localstorage-value.js.map