From 546577f1bb07149590931a16b4d00d0de4984551 Mon Sep 17 00:00:00 2001 From: User Date: Mon, 12 Jan 2026 10:09:48 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20TodoList=E3=81=AEuseEffect=E7=84=A1?= =?UTF-8?q?=E9=99=90=E3=83=AB=E3=83=BC=E3=83=97=E3=82=92=E4=BF=AE=E6=AD=A3?= =?UTF-8?q?=EF=BC=88useCallback=E3=81=A7fetchTodos=E3=82=92=E3=83=A1?= =?UTF-8?q?=E3=83=A2=E5=8C=96=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/TodoList.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/components/TodoList.tsx b/components/TodoList.tsx index 896200d..0a5a79b 100644 --- a/components/TodoList.tsx +++ b/components/TodoList.tsx @@ -1,6 +1,6 @@ 'use client' -import { useEffect, useState } from 'react' +import { useCallback, useEffect, useState } from 'react' import TodoItem from './TodoItem' export interface Todo { @@ -17,7 +17,7 @@ export default function TodoList() { const [isLoading, setIsLoading] = useState(true) const [error, setError] = useState(null) - const fetchTodos = async () => { + const fetchTodos = useCallback(async () => { try { setIsLoading(true) const response = await fetch('/api/todos') @@ -34,7 +34,7 @@ export default function TodoList() { } finally { setIsLoading(false) } - } + }, []) useEffect(() => { fetchTodos()