jniemann66 / react-chessdiagram

Chess Diagram React Component
MIT License
26 stars 10 forks source link

Attempting to call onMovePiece callback even when it isn't defined #9

Closed jniemann66 closed 7 years ago

jniemann66 commented 7 years ago

In chessdiagram.js, the introduction 'allowMoves' was a good idea. However, there should be an additional safeguard against the case where allowMoves is true, but onMovePiece is undefined.

I propose the following change to Chessdiagram.js, line 64:

_onMovePiece(pieceType, from, to) {
    if (this.props.allowMoves && this.props.onMovePiece) {
        this.props.onMovePiece(pieceType, from, to);
    }
}
jniemann66 commented 7 years ago

fixed in f4e480c2617658e353c162f1cb8e67a0ffa98a14