I have a component which takes in a prop "board" which is a piece of state and a useEffect which changes the value of board. However, even when I verify that the useEffect has been run, the component does not rerender.
This is what my component looks like:
Table rows = {game.rows} cols = {game.cols} style = {style} board = {board} key = {board} setMoveHistory = {setMoveHistory} moveHistory = {moveHistory} />
This is my useEffect:
useEffect(() => {
if(!game) return;
console.log('useEffect for setting board running');
setBoard(createFilledArray(game.rows, game.cols, moveHistory.slice(0, tempTurnNum -1)));
setRun(true);
console.log(moveHistory)
},[tempTurnNum, moveHistory, aState])
Even when the useEffect successfully resets the state variable "board", the table component does not rerender. I would appreciate it if anyone knows why.
Top comments (1)
I figured it out, I forgot to adjust the variable for turn number when I adjusted the board.