인프런 커뮤니티 질문&답변
TicTacToe.jsx 파일의 코드에 대한 질문드립니다.
작성
·
160
0
useEffect(() => {
const[row,cell] = recentCell;
if(row < 0) {
return ;
}
let win = false;
if (tableData[row][0] === turn && tableData[row][1] === turn && tableData[row][2] === turn) {
win = true;
}
if (tableData[0][cell] === turn && tableData[1][cell] === turn && tableData[2][cell] === turn) {
win = true;
}
if (tableData[0][0] === turn && tableData[1][1] === turn && tableData[2][2] === turn) {
win = true;
}
if (tableData[0][2] === turn && tableData[1][1] === turn && tableData[2][0] === turn) {
win = true;
}
...
TicTacToe.jsx에 있는 useEffect 안에서 row랑 cell이라는 변수를 사용하고 있는데 이 값은 어디에서 가져온 값인지 궁금합니다.
row,cell이라는 값을 넘기는게 Td 컴포넌트의 dispatch부분에서 밖에 없는데
이건 reducer에서 관리하는 부분으로 넘어가서 state로 return하는데 거기서 따로 넘겨주지 않는 거 같아서요..
답변 1
0
제로초(조현영)
지식공유자
const[row,cell] = recentCell;
여기서 가져오는 것입니다. recentCell[0]이 row가 되고, recentCell[1]이 cell이 됩니다.




