diff --git a/src/BoardSwitcher.js b/src/BoardSwitcher.js index 61ad96f..a8daba2 100644 --- a/src/BoardSwitcher.js +++ b/src/BoardSwitcher.js @@ -15,19 +15,32 @@ class Board extends React.Component { } class BoardSwitcher extends React.Component { + constructor(props){ + super(props); + this.state = { + spot: 0, + }; + } + + handleClick(event){ + this.setState({ + spot: (this.state.spot+1)%3 + }) + } + render() { - let boards = []; - for (let ii = 0; ii < this.props.numBoards; ii++) { - let isSelected = ii === 0; + let boards = []; // empty array of boards + for (let ii = 0; ii < this.props.numBoards; ii++) { // fill the array with n(param) boards + let isSelected = ii === this.state.spot; // let the first one be selected boards.push( - + // returns a 'Board' object with those params ); } return (
{boards}
- +
); }