Implement history form
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Siklos 2022-08-04 11:17:59 +02:00
parent fab40f5cf7
commit 964d9a0e57
2 changed files with 38 additions and 1 deletions

View file

@ -0,0 +1,29 @@
import * as React from 'react';
import { IHistoryState } from '../../App';
interface IHistoryProps {
history: IHistoryState[],
jumpTo: (move: number) => void
}
export class History extends React.Component<IHistoryProps> {
public render() {
const states = this.props.history.map((step, move) => {
const desc = move
? `Go back at turn n°${move}`
: 'Go back at the beginning';
return (
<li key={move}>
<button onClick={() => this.props.jumpTo(move)}>{desc}</button>
</li>
);
});
return (
<div>
{ states }
</div>
);
}
}