react-chessboard-ui 1.4.9 → 1.4.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -176,6 +176,7 @@ JSChessEngine.checkBeatedCell = function (state, target) {
176
176
  };
177
177
  JSChessEngine.hasFigure = function (state, pos) {
178
178
  var _state$pos$1$pos$;
179
+ if (!state[pos[1]]) return false;
179
180
  return !!((_state$pos$1$pos$ = state[pos[1]][pos[0]]) !== null && _state$pos$1$pos$ !== void 0 && _state$pos$1$pos$.figure);
180
181
  };
181
182
  JSChessEngine.checkFigureIsLongRange = function (state, figurePos) {
@@ -1044,7 +1045,7 @@ JSChessEngine.getGameResult = function (state, linesWithCheck, activeColor, reve
1044
1045
  });
1045
1046
  var countsSumResult = countsNextMoves.reduce(function (prevValue, curentValue) {
1046
1047
  return prevValue + curentValue;
1047
- });
1048
+ }, 0);
1048
1049
  if (linesWithCheck.length > 0 && countsSumResult === 0) return {
1049
1050
  resultType: 'mat',
1050
1051
  winColor: activeColor === 'white' ? 'black' : 'white'
@@ -2383,13 +2384,16 @@ var useChessBoardInteractive = function useChessBoardInteractive(props) {
2383
2384
  var clearArrows = function clearArrows() {
2384
2385
  return setArrowsCoords([]);
2385
2386
  };
2387
+ var firstRender = React.useRef(false);
2386
2388
  React.useEffect(function () {
2387
2389
  setBoardConfig(getChessBoardConfig(config));
2388
2390
  }, []);
2389
2391
  React.useEffect(function () {
2390
- if (linesWithCheck.length > 0) {
2392
+ if (firstRender.current) {
2391
2393
  var gameResult = JSChessEngine.getGameResult(actualState, linesWithCheck, currentColor, boardReversed);
2392
2394
  if (gameResult) onEndGame(gameResult);
2395
+ } else {
2396
+ firstRender.current = true;
2393
2397
  }
2394
2398
  }, [actualState, linesWithCheck, boardReversed, currentColor]);
2395
2399
  var cleanAllForFigure = function cleanAllForFigure() {