From 15370294ffef60caa9d4d25de3c4a3e613c40f60 Mon Sep 17 00:00:00 2001 From: hassanamjad1 Date: Thu, 23 Sep 2021 16:56:32 -0400 Subject: [PATCH] Adding auto-toggle Functionality --- src/BoardSwitcher.js | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/BoardSwitcher.js b/src/BoardSwitcher.js index 61ad96f..16bb4d8 100644 --- a/src/BoardSwitcher.js +++ b/src/BoardSwitcher.js @@ -15,19 +15,36 @@ class Board extends React.Component { } class BoardSwitcher extends React.Component { + state = { + iiBox : 0, + }; + toggleBox(event) { + if(this.state.iiBox >= 2){ + this.state.iiBox -=3 + } + this.setState({ + iiBox : this.state.iiBox + 1 + }); + } render() { let boards = []; + let boxNum = this.state.iiBox + // if (boxNum >2) { + // this.state.iiBox -= 2; + // } for (let ii = 0; ii < this.props.numBoards; ii++) { - let isSelected = ii === 0; + + let isSelected = ii === boxNum; boards.push( ); } + return (
{boards}
- +
); }