79745881

Date: 2025-08-25 14:41:08
Score: 1
Natty:
Report link

author of the library here, in your examples you look to be using the v4 API, v5 has a completely new API where config is passed in via the options prop. I recommend reading the docs: https://react-chessboard.vercel.app/?path=/docs/how-to-use-options-api--docs#optionsonpiececlick

// handle piece click
const onPieceClick = ({
  square,
  piece,
  isSparePiece
}: PieceHandlerArgs) => {
  console.log(piece.pieceType);
};

// chessboard options
const chessboardOptions = {
  allowDragging: false,
  onPieceClick,
  id: 'on-piece-click'
};

// render
return <Chessboard options={chessboardOptions} />;   
Reasons:
  • Probably link only (1):
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: Ryan