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:
parent
58622bbf99
commit
bc77342380
@ -1,5 +1,5 @@
|
|||||||
import useSWR, { SWRConfiguration } from 'swr';
|
import useSWR, { SWRConfiguration } from 'swr';
|
||||||
import { useCallback, useEffect } from 'react';
|
import { useCallback } from 'react';
|
||||||
import { emptyFeature } from './emptyFeature';
|
import { emptyFeature } from './emptyFeature';
|
||||||
import handleErrorResponses from '../httpErrorResponseHandler';
|
import handleErrorResponses from '../httpErrorResponseHandler';
|
||||||
import { formatApiPath } from 'utils/formatPath';
|
import { formatApiPath } from 'utils/formatPath';
|
||||||
@ -32,7 +32,7 @@ export const useFeature = (
|
|||||||
} = uiConfig;
|
} = uiConfig;
|
||||||
|
|
||||||
const { data, error, mutate } = useSWR<IFeatureResponse>(
|
const { data, error, mutate } = useSWR<IFeatureResponse>(
|
||||||
['useFeature', path],
|
['useFeature', path, variantsPerEnvironment],
|
||||||
() => featureFetcher(path, variantsPerEnvironment),
|
() => featureFetcher(path, variantsPerEnvironment),
|
||||||
options
|
options
|
||||||
);
|
);
|
||||||
@ -41,10 +41,6 @@ export const useFeature = (
|
|||||||
mutate().catch(console.warn);
|
mutate().catch(console.warn);
|
||||||
}, [mutate]);
|
}, [mutate]);
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
mutate();
|
|
||||||
}, [mutate, variantsPerEnvironment]);
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
feature: data?.body || emptyFeature,
|
feature: data?.body || emptyFeature,
|
||||||
refetchFeature,
|
refetchFeature,
|
||||||
|
Loading…
Reference in New Issue
Block a user