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:
parent
5e9698fe63
commit
8bec94da08
@ -2,8 +2,11 @@ import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig';
|
|||||||
|
|
||||||
type flags = ReturnType<typeof useUiConfig>['uiConfig']['flags'];
|
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();
|
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;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user