main #57
1 changed files with 3 additions and 2 deletions
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue