1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-20 00:08:02 +01:00

fix: too many reqs to feature toggle endpoint (#2650)

Fixes an issue where the feature toggle endpoint gets request too many
times repeatedly.
This commit is contained in:
Nuno Góis 2022-12-09 10:37:09 +00:00 committed by GitHub
parent 58622bbf99
commit bc77342380
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,5 +1,5 @@
import useSWR, { SWRConfiguration } from 'swr';
import { useCallback, useEffect } from 'react';
import { useCallback } from 'react';
import { emptyFeature } from './emptyFeature';
import handleErrorResponses from '../httpErrorResponseHandler';
import { formatApiPath } from 'utils/formatPath';
@ -32,7 +32,7 @@ export const useFeature = (
} = uiConfig;
const { data, error, mutate } = useSWR<IFeatureResponse>(
['useFeature', path],
['useFeature', path, variantsPerEnvironment],
() => featureFetcher(path, variantsPerEnvironment),
options
);
@ -41,10 +41,6 @@ export const useFeature = (
mutate().catch(console.warn);
}, [mutate]);
useEffect(() => {
mutate();
}, [mutate, variantsPerEnvironment]);
return {
feature: data?.body || emptyFeature,
refetchFeature,