fix: reset value correctly

This commit is contained in:
GyDi
2022-02-13 19:40:31 +08:00
parent 5b1fc0e6c0
commit d599be7e7c
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>