RedHatInsights/insights-rbac-ui

View on GitHub
src/helpers/shared/use-preview-flag.js

Summary

Maintainability
A
0 mins
Test Coverage
import useChrome from '@redhat-cloud-services/frontend-components/useChrome';
import { useFlag } from '@unleash/proxy-client-react';

export const usePreviewFlag = (flag) => {
  const { isBeta, getEnvironment } = useChrome();
  const flagValue = useFlag(flag);

  if (getEnvironment() === 'prod' && isBeta() === false) {
    return false;
  }

  return flagValue;
};