【发布时间】:2021-09-21 02:02:37
【问题描述】:
我有以下代码导致渲染过多。
const passAcrossSelectedGame = props => {
if (props.passedGamesFlag === 1) {
props.setPassedGamesFlag(0);
gameDetails = {
blackKingSquare: '',
whiteKingSquare: '',
};
plyViewed = 0;
setHistory(game.history());
const auxGame = new Game();
gameHistory = [];
gameHistory.push(auxGame.fen());
game.history().forEach(move => {
auxGame.move(move);
fenHistory.push(auxGame.fen());
});
}
};
passAcrossSelectedGame(props);
我已将违规行标识为 setHistory(game.history());
当我注释掉那一行时,我没有得到不断的重新渲染。但我需要它在那里!什么解决方案可能适合这个?
【问题讨论】:
标签: reactjs