"use client"; import { useCallback, useState } from "react"; export function Todo({ todos, addTodo }) { const [isLoading, setIsLoading] = useState(false); const addTodoAndRefresh = useCallback(async (formData) => { await addTodo(formData); window.location.reload(); }, []); return ( <> {isLoading &&

Adding todo...

}
{ // We're using onSubmit so that we don't have to wait for the server // to get the request before we set isLoading to true setIsLoading(true); }} >
); }