Skip to content

Commit

Permalink
fix: add isRefetching as spinner check to reset init values (#2671)
Browse files Browse the repository at this point in the history
Signed-off-by: Saurav Kumar <sauravkhdoolia@gmail.com>
Co-authored-by: Palash Gupta <palashgdev@gmail.com>
  • Loading branch information
ksorv and palashgdev committed May 12, 2023
1 parent 9da3990 commit e8f2176
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions frontend/src/pages/EditRules/index.tsx
Expand Up @@ -18,13 +18,16 @@ function EditRules(): JSX.Element {

const isValidRuleId = ruleId !== null && String(ruleId).length !== 0;

const { isLoading, data, isError } = useQuery(['ruleId', ruleId], {
queryFn: () =>
get({
id: parseInt(ruleId || '', 10),
}),
enabled: isValidRuleId,
});
const { isLoading, data, isRefetching, isError } = useQuery(
['ruleId', ruleId],
{
queryFn: () =>
get({
id: parseInt(ruleId || '', 10),
}),
enabled: isValidRuleId,
},
);

const { notifications } = useNotifications();

Expand All @@ -45,7 +48,7 @@ function EditRules(): JSX.Element {
return <div>{data?.error || t('something_went_wrong')}</div>;
}

if (isLoading || !data?.payload) {
if (isLoading || isRefetching || !data?.payload) {
return <Spinner tip="Loading Rules..." />;
}

Expand Down

0 comments on commit e8f2176

Please sign in to comment.