diff --git a/src/components/BoardSwitcher.js b/src/components/BoardSwitcher.js
index e99793a..301b69e 100644
--- a/src/components/BoardSwitcher.js
+++ b/src/components/BoardSwitcher.js
@@ -1,25 +1,29 @@
-import React from "react";
+import React, { useState } from "react";
function Board(props) {
- let className = "board";
- if (props.selected) {
- className += " selected";
- }
+ const className = `board ${props.selected ? "selected" : ""}`;
return
{props.index + 1}
;
}
function BoardSwitcher(props) {
- let boards = [];
- for (let ii = 0; ii < props.numBoards; ii++) {
- let isSelected = ii === 0;
- boards.push();
- }
+ // Initialize state to track the current selection
+ const [activeIndex, setActiveIndex] = useState(0);
+
+ // Event handler to toggle the active board
+ const handleToggleClick = () => {
+ setActiveIndex((prevIndex) => (prevIndex + 1) % props.numBoards);
+ };
+
+ // Generate the boards based on the activeIndex
+ const boards = Array.from({ length: props.numBoards }, (_, index) => (
+
+ ));
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(
-
+
);