From ecd764d3cad924259ae25648f2b425845743255d Mon Sep 17 00:00:00 2001 From: "sonya.wong" <65000266+sonyaw612@users.noreply.github.com> Date: Tue, 28 Sep 2021 20:05:51 -0400 Subject: [PATCH] Update BoardSwitcher.js --- src/BoardSwitcher.js | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/BoardSwitcher.js b/src/BoardSwitcher.js index 61ad96f..435bb48 100644 --- a/src/BoardSwitcher.js +++ b/src/BoardSwitcher.js @@ -15,10 +15,24 @@ class Board extends React.Component { } class BoardSwitcher extends React.Component { + constructor(props){ + super(props); + this.state = { + toggle: 0, + }; + } + + handleClick(event) { + this.setState({ + toggle: (this.state.toggle+1)%3 + }); + } + render() { let boards = []; + for (let ii = 0; ii < this.props.numBoards; ii++) { - let isSelected = ii === 0; + let isSelected = ii === this.state.toggle; boards.push( ); @@ -27,10 +41,11 @@ class BoardSwitcher extends React.Component { return (
{boards}
- +
); } + } export default BoardSwitcher;