From 69dc309f82127680d8c071f1b9f8d3ff888bcae3 Mon Sep 17 00:00:00 2001 From: TonsV2 Date: Mon, 3 Jul 2023 19:02:14 +0800 Subject: [PATCH] fix: refetch loop --- src/components/NewInstance.tsx | 2 +- src/components/StackConfigurator.tsx | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/components/NewInstance.tsx b/src/components/NewInstance.tsx index cd50dd15..0d2c0a84 100644 --- a/src/components/NewInstance.tsx +++ b/src/components/NewInstance.tsx @@ -114,7 +114,7 @@ export const NewInstance = () => { ))}

Stack configuration

- + {postError && ( An error occurred while saving the new instance diff --git a/src/components/StackConfigurator.tsx b/src/components/StackConfigurator.tsx index 3bb0b8d0..b821b801 100644 --- a/src/components/StackConfigurator.tsx +++ b/src/components/StackConfigurator.tsx @@ -1,4 +1,4 @@ -import { Divider, InputField, TextArea, SingleSelectField, SingleSelectOption } from '@dhis2/ui' +import { Divider, InputField, SingleSelectField, SingleSelectOption, TextArea } from '@dhis2/ui' import { getStack } from '../api/stacks' import { Stack } from '../types/stack' import { useApi } from '../api/useApi' @@ -53,7 +53,7 @@ const ttlMap = new Map([ ['1 month', 60 * 60 * 24 * 7 * 4], ]) -export const StackConfigurator = forwardRef(function StackConfigurator({ stackName, disabled }: { stackName: string; disabled: boolean }, ref) { +export const StackConfigurator = forwardRef(function StackConfigurator({ name: stackName, disabled }: { name: string; disabled: boolean }, ref) { const [name, setName] = useState('') const [description, setDescription] = useState('') const [requiredStackParameters, setRequiredStackParameters] = useState({}) @@ -81,10 +81,10 @@ export const StackConfigurator = forwardRef(function StackConfigurator({ stackNa ) useEffect(() => { - if (!isFetching && stack && stack.name !== name) { + if (!isFetching && stack && stack.name !== stackName) { refetch() } - }, [name, refetch, stack, isFetching]) + }, [stackName, refetch, stack, isFetching]) useEffect(() => { if (stack) {