From 1706336257cf4a21849e427ec609cd702366404c Mon Sep 17 00:00:00 2001 From: ImaginandoyCreando Date: Fri, 20 Mar 2026 18:08:53 -0500 Subject: [PATCH] Refactor handleChange to use event value directly --- src/components/List.tsx | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/components/List.tsx b/src/components/List.tsx index 84b8d1d..b1824d7 100644 --- a/src/components/List.tsx +++ b/src/components/List.tsx @@ -6,12 +6,11 @@ const List: React.FC = () => { const [data, setData] = useState([]); const [filterText, setFilterText] = useState(""); - const handleChange = async (event: any) => { try { - setFilterText(event.target.value); - - const response = await fetch(`https://api.disneyapi.dev/character?name=${filterText}`); + const value = event.target.value; + setFilterText(value); + const response = await fetch(`https://api.disneyapi.dev/character?name=${value}`); if (!response.ok) { throw new Error(`Error HTTP: ${response.status}`); } @@ -60,4 +59,4 @@ const List: React.FC = () => { ); }; -export default List; \ No newline at end of file +export default List;