1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-08-13 13:48:59 +02:00

fix(1-3363): frontend flag type should not return truthy for variant

This commit is contained in:
Tymoteusz Czech 2025-02-11 13:48:17 +01:00
parent 5e9698fe63
commit 8bec94da08
No known key found for this signature in database
GPG Key ID: 133555230D88D75F

View File

@ -2,8 +2,11 @@ import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig';
type flags = ReturnType<typeof useUiConfig>['uiConfig']['flags'];
export const useUiFlag = <K extends keyof flags>(flag: K) => {
export const useUiFlag = <K extends keyof flags>(flag: K): boolean => {
const { uiConfig } = useUiConfig();
if (typeof uiConfig?.flags?.[flag] !== 'boolean') {
console.error(`Flag ${flag} is undefined or a variant.`);
}
return uiConfig?.flags?.[flag] || false;
return Boolean(uiConfig?.flags?.[flag]) || false;
};