Fetching remote data from the REST service works, basic drawing too.
That's a first prototype.
This commit is contained in:
parent
aa8ddde965
commit
fee75ff8a7
8 changed files with 190 additions and 3696 deletions
23
src/App.js
23
src/App.js
|
|
@ -1,16 +1,21 @@
|
|||
import React from 'react';
|
||||
import React, {useState} from 'react';
|
||||
import Maze from "./Maze";
|
||||
import {maze1, maze2, maze3} from "./testdata";
|
||||
import InputForm from "./InputForm";
|
||||
|
||||
export default function Square() {
|
||||
const mazes = [{grid: [[]]}, maze1, maze2, maze3];
|
||||
const renderedMazes = mazes.map(maze => (<div>
|
||||
<h1>The Maze ({maze.width}x{maze.height}).</h1>
|
||||
<Maze labyrinth={maze}/>
|
||||
</div>))
|
||||
export default function App() {
|
||||
const [maze, setMaze] = useState({});
|
||||
let title;
|
||||
if (!!maze.grid) {
|
||||
title = <h1>The Maze ({maze.width}x{maze.height})</h1>;
|
||||
} else {
|
||||
title = <span/>;
|
||||
}
|
||||
return (
|
||||
<div>
|
||||
{renderedMazes}
|
||||
<InputForm handleResult={setMaze}/>
|
||||
{title}
|
||||
<Maze labyrinth={maze}
|
||||
showSolution={true}/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue