handlePlyChange passed as prop to useEffect is being recreated every time state changes, so wrapper in useCallback

This commit is contained in:
2026-06-02 20:26:47 +02:00
parent 7d8f390a50
commit 1251921ea1
2 changed files with 11 additions and 5 deletions
+2 -2
View File
@@ -20,7 +20,7 @@ const PgnViewer = ({ gamePgn, handlePlyChange }: IProps) => {
scrollToMove: false,
});
// set initial position - TODO change onto file load
// set initial position - TODO change to on file load
// handlePlyChange({
// ply: 0,
// fen: viewerRef.current?.curData().fen,
@@ -78,7 +78,7 @@ const PgnViewer = ({ gamePgn, handlePlyChange }: IProps) => {
move.removeEventListener("touchstart", clickHandlerDelay);
});
};
}, [gamePgn]);
}, [gamePgn, handlePlyChange]);
return <div ref={containerRef} className="lpv-board" />;
};