mirror of
https://github.com/andwati/dokploy.git
synced 2026-11-20 11:08:46 +00:00
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:
@@ -66,19 +66,13 @@ export const AddCommand = ({ applicationId }: Props) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (data?.command) {
|
if (data) {
|
||||||
form.reset({
|
form.reset({
|
||||||
command: data?.command || "",
|
command: data?.command || "",
|
||||||
args: data?.args?.map((arg) => ({ value: arg })) || [],
|
args: data?.args?.map((arg) => ({ value: arg })) || [],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, [
|
}, [data, form]);
|
||||||
form,
|
|
||||||
form.reset,
|
|
||||||
form.formState.isSubmitSuccessful,
|
|
||||||
data?.command,
|
|
||||||
data?.args,
|
|
||||||
]);
|
|
||||||
|
|
||||||
const onSubmit = async (data: AddCommand) => {
|
const onSubmit = async (data: AddCommand) => {
|
||||||
await mutateAsync({
|
await mutateAsync({
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ export const ShowCustomCommand = ({ id, type }: Props) => {
|
|||||||
args: data.args?.map((arg) => ({ value: arg })) || [],
|
args: data.args?.map((arg) => ({ value: arg })) || [],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, [data, form, form.reset]);
|
}, [data, form]);
|
||||||
|
|
||||||
const onSubmit = async (formData: AddDockerImage) => {
|
const onSubmit = async (formData: AddDockerImage) => {
|
||||||
await mutateAsync({
|
await mutateAsync({
|
||||||
|
|||||||
Reference in New Issue
Block a user