題名の通りreact-hook-formでuseMutationを使いたいです.
下記のコードでonSubmitで型エラーは発生してしまいます.
解決策をご存知の方はよろしくお願いします
const ADD_TODO = gql` mutation MyMutation { insert_news(objects: { title: $title }) { affected_rows } } `; const Home = () => { const [addTodo] = useMutation(ADD_TODO); return ( <form onSubmit={handleSubmit(onSubmit)} style={{ width: "200px" }}> {console.log(errors)} <TextFeild label="title" name="title" err={!!errors.title} hoge={register({ required: true })} /> <TextFeild label="title1" name="title1" err={!!errors.title1} hoge={register({ required: true })} /> <Button type="submit" color="primary" variant="contained"> submit </Button> </form> ) }
Argument of type '(data: { title: string; }) => Promise<FetchResult<any, Record<string, any>, Record<string, any>>>' is not assignable to parameter of type 'SubmitHandler<IFormInputs>'. Type 'Promise<FetchResult<any, Record<string, any>, Record<string, any>>>' is not assignable to type 'void | Promise<void>'. Type 'Promise<FetchResult<any, Record<string, any>, Record<string, any>>>' is not assignable to type 'Promise<void>'. Type 'FetchResult<any, Record<string, any>, Record<string, any>>' is not assignable to type 'void'.
あなたの回答
tips
プレビュー