From a15c3fe72bdf804b03740c0f3b987ae3257a8268 Mon Sep 17 00:00:00 2001 From: Owen Liang Date: Fri, 22 Sep 2023 20:17:18 -0400 Subject: [PATCH] lab done --- src/components/BoardSwitcher.js | 19 ++++++++++++++++--- src/index.js | 2 +- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/components/BoardSwitcher.js b/src/components/BoardSwitcher.js index e99793a..21e3b53 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"; @@ -11,15 +11,28 @@ function Board(props) { function BoardSwitcher(props) { let boards = []; + + const [currentBoard, setCurrentBoard] = useState(0); + + const handleToggle = (event) => { + if(currentBoard >= props.numBoards - 1) { + setCurrentBoard(0); + } + else { + setCurrentBoard(currentBoard + 1); + } + + } + for (let ii = 0; ii < props.numBoards; ii++) { - let isSelected = ii === 0; + let isSelected = ii === currentBoard; 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( - + );