Move to Typescript.
This commit is contained in:
parent
34618860a4
commit
ac964ddd3f
16 changed files with 482 additions and 119 deletions
22
src/Maze.tsx
Normal file
22
src/Maze.tsx
Normal file
|
@ -0,0 +1,22 @@
|
|||
import Cell from "./Cell.tsx";
|
||||
|
||||
|
||||
export default function Maze({state, dispatch}) {
|
||||
if (!state.maze) {
|
||||
return <div>No valid maze.</div>
|
||||
}
|
||||
|
||||
let maze: JSX.Element[] = [];
|
||||
for (let y = 0; y < state.maze.height; y++) {
|
||||
let row: JSX.Element[] = [];
|
||||
for (let x = 0; x < state.maze.width; x++) {
|
||||
row.push(<Cell key={`${x}x${y}`} x={x} y={y} state={state} dispatch={dispatch}/>)
|
||||
}
|
||||
maze.push(<div key={`r${y}`} className={"row"}>{row}</div>);
|
||||
}
|
||||
return (
|
||||
<div className={"maze"}>
|
||||
{maze}
|
||||
</div>
|
||||
);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue