diff --git a/src/BoardSwitcher.js b/src/BoardSwitcher.js index 61ad96f..c656b3e 100644 --- a/src/BoardSwitcher.js +++ b/src/BoardSwitcher.js @@ -15,10 +15,35 @@ class Board extends React.Component { } class BoardSwitcher extends React.Component { + + // set it to 0 + state = { + clicks: 0, + }; + + // increase 1 when user clicks + handleClick(event) { + this.setState({ + clicks: this.state.clicks + 1 + }); + } + render() { + let boards = []; for (let ii = 0; ii < this.props.numBoards; ii++) { - let isSelected = ii === 0; + + + // Line 37 - 45 is new code + + // when the number is 3, clicks beack to 0 + if(this.state.clicks === 3){ + this.state.clicks = 0; + } + + // let isSelected = ii === 0; the number can be 0, 1 , 2 + let isSelected = ii === this.state.clicks; + boards.push( ); @@ -27,7 +52,7 @@ class BoardSwitcher extends React.Component { return (
{boards}
- +
); }