mirror of
https://github.com/Unleash/unleash.git
synced 2025-06-27 01:19:00 +02:00
fix: now feature is not pulled from server if not defined (#10000)
This commit is contained in:
parent
45c2a0b939
commit
0255cf137a
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user