error fix Models.tsx

This commit is contained in:
YasinOnm08 2024-09-26 16:09:45 +02:00
parent 9b48be0202
commit 85deb5d64b

View file

@ -29,12 +29,13 @@ const modelDropdown = {
const Models: React.FC = () => {
// Initialize state with value from localStorage or default to ''
const [radioSelection, setRadioSelection] = useState(() => localStorage.getItem('radioSelection') || '');
const [radioSelection, setRadioSelection] = useState('');
useEffect(() => {
const handleStorageChange = () => {
setRadioSelection(localStorage.getItem('radioSelection') || '');
};
handleStorageChange()
// Update dropdown immediately when localStorage changes internally or externally
window.addEventListener('storage', handleStorageChange);