Created
July 3, 2020 14:32
-
-
Save marcoemrich/413779f8fd03803e62594595b74fab35 to your computer and use it in GitHub Desktop.
JS Testing: board.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, {useState} from 'react' | |
import {Cell} from "./cell.js" | |
import * as R from 'ramda' | |
const mapIndexed = R.addIndex(R.map); | |
export const Board = props => { | |
const [state, setState] = useState(props.game); | |
const handleCellClick = e => setState(state.mark(Number(e.target.dataset["cellNr"]))); | |
return <div className="board"> | |
{ | |
mapIndexed((cellContent, i) => | |
<Cell | |
key={i} | |
cellNr={i} | |
onClick={handleCellClick} | |
owner={cellContent} | |
/> | |
, state.fields) | |
} | |
</div>; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment