1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-09-01 13:47:27 +02:00

fix: useUiFlag type

This commit is contained in:
Tymoteusz Czech 2025-02-11 14:03:42 +01:00
parent 8bec94da08
commit 60d3df3282
No known key found for this signature in database
GPG Key ID: 133555230D88D75F

View File

@ -4,9 +4,12 @@ type flags = ReturnType<typeof useUiConfig>['uiConfig']['flags'];
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.`);
const value = uiConfig?.flags?.[flag];
if (typeof value === 'boolean') {
return value;
} else if (typeof value !== 'undefined') {
console.error(`Flag ${flag} does not return a boolean.`);
}
return Boolean(uiConfig?.flags?.[flag]) || false;
return false;
};