aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreug-vs <eugene@eug-vs.xyz>2022-05-06 18:42:05 +0400
committereug-vs <eugene@eug-vs.xyz>2022-05-06 18:42:05 +0400
commit3e3e29527f7bf7b72363a1193b3ee310b1adc2fa (patch)
tree609bb8195b2c771d084b8a4e9e7ac3b2a3a561f7
parentc29168ba478e74e285e4230785af90deddfc396a (diff)
downloadchrono-cube-ui-3e3e29527f7bf7b72363a1193b3ee310b1adc2fa.tar.gz
feat: allow removing solutions
-rw-r--r--src/index.tsx9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/index.tsx b/src/index.tsx
index c6cab71..1bdd41a 100644
--- a/src/index.tsx
+++ b/src/index.tsx
@@ -19,6 +19,10 @@ const App: React.FC = () => {
setSolutions([{ author, result }, ...solutions]);
}
+ const handleRemoveSolution = (index: number) => {
+ setSolutions(solutions.filter((_, i) => i !== index));
+ }
+
return (
<>
<h2>Timer</h2>
@@ -26,9 +30,10 @@ const App: React.FC = () => {
<h2>Results</h2>
<ul>
- {solutions.map(solution => (
+ {solutions.map((solution, index) => (
<li>
- {solution.result} by {solution.author}
+ {solution.result} by {solution.author} &nbsp;
+ <button onClick={() => handleRemoveSolution(index)}>remove</button>
</li>
))}
</ul>