Skip to content

Commit 825a127

Browse files
committed
fix: lint and popover state tracking repetition
1 parent 15b82b9 commit 825a127

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

kaggle_environments/envs/open_spiel_env/games/go/visualizer/v2/src/components/HeroAnimation.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ export default function HeroAnimation() {
8383
clearTimeout(timeout);
8484
setHero(null);
8585
};
86-
}, [game]);
86+
}, [game, showHeroAnimations]);
8787

8888
const isVisible = !!hero && !game.gameOver;
8989

kaggle_environments/envs/open_spiel_env/games/go/visualizer/v2/src/components/WithPopover.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,18 @@ interface Props {
1414
}
1515

1616
export function WithPopover({ children, icon, id, label, onChange }: Props) {
17-
const [open, setOpen] = useState<boolean | undefined>();
17+
const [open, setOpen] = useState(false);
18+
const onChangeRef = useRef(open);
1819
const transition = useTransition({ duration: 0.2, ease: 'easeOut' });
1920
const iconPath = `${svgSymbolPath}#${icon}`;
2021
const triggerRef = useRef<HTMLButtonElement>(null);
2122
const panelRef = useRef<HTMLDivElement>(null);
2223

2324
useEffect(() => {
24-
if (open !== undefined && onChange) onChange(open);
25+
if (onChange && onChangeRef.current !== open) {
26+
onChangeRef.current = open;
27+
onChange(open);
28+
}
2529

2630
if (!open) return;
2731

@@ -50,7 +54,7 @@ export function WithPopover({ children, icon, id, label, onChange }: Props) {
5054
document.removeEventListener('mousedown', handleMouseDown);
5155
document.removeEventListener('keydown', handleKeyDown);
5256
};
53-
}, [open]);
57+
}, [open, onChange]);
5458

5559
return (
5660
<div className={styles.wrapper}>

0 commit comments

Comments
 (0)