From 3e3e29527f7bf7b72363a1193b3ee310b1adc2fa Mon Sep 17 00:00:00 2001
From: eug-vs <eugene@eug-vs.xyz>
Date: Fri, 6 May 2022 18:42:05 +0400
Subject: feat: allow removing solutions

---
 src/index.tsx | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

(limited to 'src/index.tsx')

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>
-- 
cgit v1.2.3

