diff --git a/src/components/BoardSwitcher.jsx b/src/components/BoardSwitcher.jsx index e99793a..7272cf0 100644 --- a/src/components/BoardSwitcher.jsx +++ b/src/components/BoardSwitcher.jsx @@ -1,4 +1,4 @@ -import React from "react"; +import React, { useState } from "react"; function Board(props) { let className = "board"; @@ -6,20 +6,29 @@ function Board(props) { className += " selected"; } - return
{props.index + 1}
; + return
{props.index}
; } function BoardSwitcher(props) { + const [selectedBoardIndex, setSelectedBoardIndex] = useState(0); + + const handleClick = (event) => { + setSelectedBoardIndex((selectedBoardIndex + 1) % props.numBoards); + + } + + let boards = []; - for (let ii = 0; ii < props.numBoards; ii++) { - let isSelected = ii === 0; - boards.push(); + for (let boardIndex = 0; boardIndex < props.numBoards; boardIndex++) { + let isBoardSelected = boardIndex === selectedBoardIndex; + boards.push(); } + return (
{boards}
- +
); }