This commit is contained in:
Ole
2026-05-31 20:25:41 +00:00
commit 0a07ab8593
275 changed files with 52660 additions and 0 deletions
@@ -0,0 +1,17 @@
import { useRef, useMemo } from 'react';
import { useTodoList } from './useTodoList';
import { createTodoWriteTool } from './todoWriteTool';
export function useTodoWriteTool() {
const { todos, setTodos } = useTodoList();
// Keep a ref so the memoized execute closure always reads current state.
const todosRef = useRef(todos);
todosRef.current = todos;
return useMemo(
() => createTodoWriteTool({ getTodos: () => todosRef.current, setTodos }),
// setTodos is stable (from useMemo in TodoProvider), so the tool identity is stable.
[setTodos]
);
}