Skip to content

Commit 75a4979

Browse files
author
Mauricio Siu
committed
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.
1 parent 716e8b3 commit 75a4979

File tree

2 files changed

+3
-9
lines changed

2 files changed

+3
-9
lines changed

apps/dokploy/components/dashboard/application/advanced/general/add-command.tsx

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,19 +66,13 @@ export const AddCommand = ({ applicationId }: Props) => {
6666
});
6767

6868
useEffect(() => {
69-
if (data?.command) {
69+
if (data) {
7070
form.reset({
7171
command: data?.command || "",
7272
args: data?.args?.map((arg) => ({ value: arg })) || [],
7373
});
7474
}
75-
}, [
76-
form,
77-
form.reset,
78-
form.formState.isSubmitSuccessful,
79-
data?.command,
80-
data?.args,
81-
]);
75+
}, [data, form]);
8276

8377
const onSubmit = async (data: AddCommand) => {
8478
await mutateAsync({

apps/dokploy/components/dashboard/postgres/advanced/show-custom-command.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ export const ShowCustomCommand = ({ id, type }: Props) => {
8787
args: data.args?.map((arg) => ({ value: arg })) || [],
8888
});
8989
}
90-
}, [data, form, form.reset]);
90+
}, [data, form]);
9191

9292
const onSubmit = async (formData: AddDockerImage) => {
9393
await mutateAsync({

0 commit comments

Comments
 (0)