Javascript 状态更改时不重新渲染
我需要红色的冷红细胞。 但是我得了蓝色,我做错了什么 我有一个功能,检查防止单元格,并标记单元格 AI_单元=红色Javascript 状态更改时不重新渲染,javascript,html,reactjs,html-table,Javascript,Html,Reactjs,Html Table,我需要红色的冷红细胞。 但是我得了蓝色,我做错了什么 我有一个功能,检查防止单元格,并标记单元格 AI_单元=红色 突出显示单元格=蓝色 用户\单元=绿色 const checkWinnerScore = () => { let [y, x] = prevCell; let copyCells = JSON.parse(JSON.stringify(cells)); if (copyCells[y][x] === HIGHLIGHT_CELL) {
突出显示单元格=蓝色
用户\单元=绿色
const checkWinnerScore = () => {
let [y, x] = prevCell;
let copyCells = JSON.parse(JSON.stringify(cells));
if (copyCells[y][x] === HIGHLIGHT_CELL) {
// I assign value, but cell do not coolerd in red.
copyCells[y][x] = AI_CELL;
setCells(copyCells);
setAiScore(aiScore + 1);
} else if (copyCells[y][x] === AI_CELL) {
return;
}
};
codesandbox中的完整示例: