fix: updated the form value on mount (#4076)

* fix: updated the form value on mount

* fix: isLoading is replaced isFetching
This commit is contained in:
Palash Gupta 2023-11-28 13:44:25 +05:30 committed by GitHub
parent 780a863943
commit 16839eb7d3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 3 deletions

View File

@ -22,7 +22,7 @@ import {
import FormAlertChannels from 'container/FormAlertChannels';
import { useNotifications } from 'hooks/useNotifications';
import history from 'lib/history';
import { useCallback, useState } from 'react';
import { useCallback, useEffect, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { useParams } from 'react-router-dom';
@ -57,6 +57,12 @@ function EditAlertChannels({
setType(value as ChannelType);
}, []);
useEffect(() => {
formInstance.setFieldsValue({
...initialValue,
});
}, [formInstance, initialValue]);
const prepareSlackRequest = useCallback(
() => ({
api_url: selectedConfig?.api_url || '',

View File

@ -18,7 +18,7 @@ function ChannelsEdit(): JSX.Element {
const { id } = useParams<Params>();
const { t } = useTranslation();
const { isLoading, isError, data } = useQuery(['getChannel', id], {
const { isFetching, isError, data } = useQuery(['getChannel', id], {
queryFn: () =>
get({
id,
@ -29,7 +29,7 @@ function ChannelsEdit(): JSX.Element {
return <Typography>{data?.error || t('something_went_wrong')}</Typography>;
}
if (isLoading || !data?.payload) {
if (isFetching || !data?.payload) {
return <Spinner tip="Loading Channels..." />;
}