fix: reset value correctly

This commit is contained in:
GyDi 2022-02-13 19:40:31 +08:00
parent 5b779b4f14
commit 2dfd725ee0
No known key found for this signature in database
GPG Key ID: 1C95E0D3467B3084
2 changed files with 9 additions and 2 deletions

View File

@ -1,4 +1,4 @@
import { useState } from "react";
import { useEffect, useState } from "react";
import {
Button,
Dialog,
@ -28,6 +28,13 @@ const ProfileNew = (props: Props) => {
onSubmit(name, desc);
};
useEffect(() => {
if (!open) {
setName("");
setDesc("");
}
}, [open]);
return (
<Dialog open={open} onClose={onClose}>
<DialogTitle>Create Profile</DialogTitle>

View File

@ -104,8 +104,8 @@ const ProfilePage = () => {
try {
await newProfile(name, desc);
mutate("getProfiles");
setDialogOpen(false);
mutate("getProfiles");
} catch (err: any) {
err && Notice.error(err.toString());
} finally {