fix: use .watch() to disable update btn (#5482)

* fix: use .watch() to disable update btn

* Apply suggestions from code review

Co-authored-by: Peer Richelsen <peeroke@gmail.com>
Co-authored-by: Omar López <zomars@me.com>
Co-authored-by: alannnc <alannnc@gmail.com>
pull/5476/head^2
Udit Takkar 2022-11-12 01:57:09 +05:30 committed by GitHub
parent 7f14e00119
commit 9092addd9c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 3 deletions

View File

@ -155,8 +155,7 @@ const ProfileView = () => {
const {
reset,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
formState: { dirtyFields },
formState: { isSubmitting, isDirty },
} = formMethods;
useEffect(() => {
@ -197,6 +196,7 @@ const ProfileView = () => {
};
if (isLoading || !user) return <SkeletonLoader />;
const isDisabled = isSubmitting || !isDirty;
return (
<>
@ -261,7 +261,12 @@ const ProfileView = () => {
<TextField label={t("about")} hint={t("bio_hint")} {...formMethods.register("bio")} />
</div>
<Button color="primary" className="mt-8" type="submit" loading={mutation.isLoading}>
<Button
disabled={isDisabled}
color="primary"
className="mt-8"
type="submit"
loading={mutation.isLoading}>
{t("update")}
</Button>