scrimba
Tic Tac Toe
renderMoves function and the last JSX
Go Pro!Bootcamp

Bootcamp

Study group

Collaborate with peers in your dedicated #study-group channel.

Code reviews

Submit projects for review using the /review command in your #code-reviews channel

renderMoves function and the last JSX
AboutCommentsNotes
renderMoves function and the last JSX
Expand for more info
components
Game.js
run
preview
console
import React, { useState } from 'react';
import { calculateWinner } from '../helpers';
import Board from './Board';

const Game = () => {
const [board, setBoard] = useState(Array(9).fill(null));
const [xIsNext, setXisNext] = useState(true);
const winner = calculateWinner(board);

const handleClick = i => {
const boardCopy = [...board];
// If user click an occupied square or if game is won, return
if (winner || boardCopy[i]) return;
// Put an X or an O in the clicked square
boardCopy[i] = xIsNext ? 'X' : 'O';
setBoard(boardCopy);
setXisNext(!xIsNext);
}

const jumpTo = () => {

}

const renderMoves = () => {

}

return (
<Board squares={board} onClick={handleClick} />
)
}

export default Game;
Console
/index.html
-5:05