refactor: simplify useEffect dependencies in AddCommand and ShowCustomCommand components

- Updated the useEffect hooks to remove unnecessary dependencies, improving performance and readability.
- Ensured that the form resets correctly based on the presence of data.
This commit is contained in:
Mauricio Siu
2025-11-30 19:07:59 -06:00
parent 716e8b351f
commit 75a49790ea
2 changed files with 3 additions and 9 deletions

View File

@@ -66,19 +66,13 @@ export const AddCommand = ({ applicationId }: Props) => {
});
useEffect(() => {
if (data?.command) {
if (data) {
form.reset({
command: data?.command || "",
args: data?.args?.map((arg) => ({ value: arg })) || [],
});
}
}, [
form,
form.reset,
form.formState.isSubmitSuccessful,
data?.command,
data?.args,
]);
}, [data, form]);
const onSubmit = async (data: AddCommand) => {
await mutateAsync({

View File

@@ -87,7 +87,7 @@ export const ShowCustomCommand = ({ id, type }: Props) => {
args: data.args?.map((arg) => ({ value: arg })) || [],
});
}
}, [data, form, form.reset]);
}, [data, form]);
const onSubmit = async (formData: AddDockerImage) => {
await mutateAsync({