import { useForm } from 'react-hook-form'; import { useCreateTodo } from './api'; export const NewTodo: React.VFC = () => { const mutation = useCreateTodo(); const { register, handleSubmit, reset, formState: { errors }, } = useForm<{ value: string; }>(); if (mutation.isLoading) { return
Adding todo...
; } return (
{ await mutation.mutate(data.value); reset(); })} > {mutation.isError ? (
An error occurred while saving this todo
) : null}
); };