Implement history form
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
fab40f5cf7
commit
964d9a0e57
2 changed files with 38 additions and 1 deletions
29
src/Components/History/History.tsx
Normal file
29
src/Components/History/History.tsx
Normal 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>
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue