fix: synchronize initial price analysis selection
This commit is contained in:
@@ -13,7 +13,9 @@ export const PriceAnalysis = () => {
|
||||
const [selectedKey, setSelectedKey] = useState(null);
|
||||
|
||||
useEffect(() => {
|
||||
if (selectedKey && !items.some((item) => `${item.ad}||${item.birim}` === selectedKey)) setSelectedKey(null);
|
||||
if (!items.length) { if (selectedKey !== null) setSelectedKey(null); return; }
|
||||
if (!selectedKey || !items.some((item) => `${item.ad}||${item.birim}` === selectedKey))
|
||||
setSelectedKey(`${items[0].ad}||${items[0].birim}`);
|
||||
}, [items, selectedKey]);
|
||||
|
||||
const selected = useMemo(() => {
|
||||
|
||||
Reference in New Issue
Block a user