aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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>