flowbite-react
Version:
Official React components built for Flowbite and Tailwind CSS
20 lines (17 loc) • 499 B
JavaScript
'use client';
import { useEffect } from 'react';
const 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.mjs.map