mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 12:56:41 +07:00
#34 added isLoading and error handling to useCommentFormFormik
This commit is contained in:
parent
8ae2dc02f0
commit
d7b4fbf535
2 changed files with 50 additions and 13 deletions
|
@ -2,6 +2,7 @@ import React, { FC, useState } from 'react';
|
|||
import { CommentFormValues, useCommentFormFormik } from '~/utils/hooks/useCommentFormFormik';
|
||||
import { FormikProvider } from 'formik';
|
||||
import { LocalCommentFormTextarea } from '~/components/comment/LocalCommentFormTextarea';
|
||||
import { Button } from '~/components/input/Button';
|
||||
|
||||
interface IProps {}
|
||||
|
||||
|
@ -13,12 +14,19 @@ const initialValues: CommentFormValues = {
|
|||
|
||||
const LocalCommentForm: FC<IProps> = () => {
|
||||
const [textarea, setTextarea] = useState<HTMLTextAreaElement>();
|
||||
const { formik, isLoading } = useCommentFormFormik(initialValues, console.log);
|
||||
const { formik } = useCommentFormFormik(initialValues);
|
||||
|
||||
return (
|
||||
<FormikProvider value={formik}>
|
||||
<LocalCommentFormTextarea isLoading={isLoading} setRef={setTextarea} />
|
||||
</FormikProvider>
|
||||
<form onSubmit={formik.handleSubmit}>
|
||||
<FormikProvider value={formik}>
|
||||
<LocalCommentFormTextarea isLoading={formik.isSubmitting} setRef={setTextarea} />
|
||||
{formik.isSubmitting && <div>LOADING</div>}
|
||||
{!!formik.status && <div>error: {formik.status}</div>}
|
||||
<Button size="small" disabled={formik.isSubmitting}>
|
||||
SEND
|
||||
</Button>
|
||||
</FormikProvider>
|
||||
</form>
|
||||
);
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue