diff --git a/src/components/BoardSwitcher.jsx b/src/components/BoardSwitcher.jsx
index e99793a..c1c8403 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";
@@ -10,16 +10,24 @@ function Board(props) {
}
function BoardSwitcher(props) {
+ // add state to track current selection
+ // state variable
+ const [selectedBoardIndex, setSelectedBoardIndex] = useState(0);
+ // create an event handler
+ const handleClick = (event) => {
+ // use the getter when trying to update the setter of state variable
+ setSelectedBoardIndex((selectedBoardIndex + 1) % props.numBoards);
+ }
let boards = [];
- for (let ii = 0; ii < props.numBoards; ii++) {
- let isSelected = ii === 0;
- boards.push(