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

fix: now feature is not pulled from server if not defined (#10000)

This commit is contained in:
Jaanus Sellin 2025-05-15 11:54:40 +03:00 committed by GitHub
parent 45c2a0b939
commit 0255cf137a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,9 +1,10 @@
import useSWR, { type SWRConfiguration } from 'swr';
import type { SWRConfiguration } from 'swr';
import { useCallback } from 'react';
import { emptyFeature } from './emptyFeature.js';
import handleErrorResponses from '../httpErrorResponseHandler.js';
import { emptyFeature } from './emptyFeature.ts';
import handleErrorResponses from '../httpErrorResponseHandler.ts';
import { formatApiPath } from 'utils/formatPath';
import type { IFeatureToggle } from 'interfaces/featureToggle';
import { useConditionalSWR } from '../useConditionalSWR/useConditionalSWR.ts';
export interface IUseFeatureOutput {
feature: IFeatureToggle;
@ -25,7 +26,9 @@ export const useFeature = (
): IUseFeatureOutput => {
const path = formatFeatureApiPath(projectId, featureId);
const { data, error, mutate } = useSWR<IFeatureResponse>(
const { data, error, mutate } = useConditionalSWR<IFeatureResponse>(
Boolean(featureId && projectId),
{ status: 404 },
['useFeature', path],
() => featureFetcher(path),
options,