Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[manager-components]: Allow useFeatureAvailability options override #14465

Open
1 task done
JacquesLarique opened this issue Dec 6, 2024 · 0 comments
Open
1 task done
Assignees

Comments

@JacquesLarique
Copy link
Contributor

Have you already checked if a similar item is present on manager-components?

  • Yes, I have already checked the existing components/hooks/utils.

What do you expect from this request?

Hook

Description

When using useFeatureAvailability hook we may need to override query options, for example if we only want to fetch feature availability in some cases it would be nice to tell tanstack that the request is enabled only in these cases.

To do so we could modify the code as such:

export const useFeatureAvailability = <T extends string[]>(
  featureList: [...T],
  options: Partial<DefinedInitialDataOptions<Record<(typeof featureList)[number], boolean>>> = {},
) : UseFeatureAvailabilityResult<
  Record<(typeof featureList)[number], boolean>
> =>
  useQuery<Record<(typeof featureList)[number], boolean>, ApiError>({
    ...options,
    queryKey: getFeatureAvailabilityQueryKey(featureList),
    queryFn: () => fetchFeatureAvailabilityData(featureList),
  });

This way we can configure the request as wanted (in any context) without impacting the behavior (as we don't override the queryKey and queryFn)

Where do you expect to use this?

packages/manager-react-components/src/hooks/feature-availability/useFeatureAvailability.ts

Do you have mock-up?

No response

When do you expect this to be delivered?

No response

Additional Information

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant