Skip to content

Commit

Permalink
fix: refetch loop
Browse files Browse the repository at this point in the history
  • Loading branch information
tonsV2 committed Jul 3, 2023
1 parent ef8d6c3 commit 69dc309
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/components/NewInstance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export const NewInstance = () => {
))}
</SingleSelectField>
<h4 className={styles.subheader}>Stack configuration</h4>
<StackConfigurator stackName={selectedStack.name} ref={stackConfiguratorRef} disabled={isPosting} />
<StackConfigurator name={selectedStack.name} ref={stackConfiguratorRef} disabled={isPosting} />
{postError && (
<NoticeBox error title="Save error" className={styles.error}>
An error occurred while saving the new instance
Expand Down
8 changes: 4 additions & 4 deletions src/components/StackConfigurator.tsx
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -53,7 +53,7 @@ const ttlMap = new Map<string, number>([
['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({})
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 69dc309

Please sign in to comment.