Skip to content

Instantly share code, notes, and snippets.

@marcoemrich
Created July 3, 2020 14:32
Show Gist options
  • Save marcoemrich/413779f8fd03803e62594595b74fab35 to your computer and use it in GitHub Desktop.
Save marcoemrich/413779f8fd03803e62594595b74fab35 to your computer and use it in GitHub Desktop.
JS Testing: board.js
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