diff --git a/src/components/BoardSwitcher.js b/src/components/BoardSwitcher.js index e99793a..725c2e1 100644 --- a/src/components/BoardSwitcher.js +++ b/src/components/BoardSwitcher.js @@ -1,4 +1,4 @@ -import React from "react"; +import React, { useState } from "react"; function Board(props) { let className = "board"; @@ -10,16 +10,25 @@ function Board(props) { } function BoardSwitcher(props) { + const [selectedBoardIndex, setSelectedBoardIndex] = useState(0); + + const toggleBoard = () => { + setSelectedBoardIndex((prevIndex) => { + + return (prevIndex + 1) % props.numBoards; + }); + }; + let boards = []; for (let ii = 0; ii < props.numBoards; ii++) { - let isSelected = ii === 0; + const isSelected = ii === selectedBoardIndex; boards.push(); } return (
{boards}
- +
); } diff --git a/src/index.js b/src/index.js index 782f402..316ad56 100644 --- a/src/index.js +++ b/src/index.js @@ -6,6 +6,6 @@ import "./index.css"; const root = ReactDOM.createRoot(document.getElementById("root")); root.render( - + );