blob: c6cab713f4d51f898a690ec1c7fadd16abc40ad1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
import React, { useState } from 'react';
import ReactDOM from 'react-dom';
import './style.css';
import './fonts/Bitter-Regular.woff';
import useLocalStorage from './hooks/useLocalStorage';
import Timer from './components/Timer';
interface Solution {
result: string;
author: string;
}
const App: React.FC = () => {
const [author, setAuthor] = useState<string>('anonymous');
const [solutions, setSolutions] = useLocalStorage<Solution[]>('solutions', []);
const registerResult = (result: string) => {
setSolutions([{ author, result }, ...solutions]);
}
return (
<>
<h2>Timer</h2>
<Timer registerResult={registerResult} />
<h2>Results</h2>
<ul>
{solutions.map(solution => (
<li>
{solution.result} by {solution.author}
</li>
))}
</ul>
</>
);
};
ReactDOM.render(<App />, document.getElementById('root'));
|