Files
supabase/apps/studio/hooks/ui/useFlag.ts
Joshen Lim 25bf3eae89 Silence config cat warnings (#29034)
* Silence config cat warnings

* Refactor
2024-09-03 11:09:13 +07:00

18 lines
473 B
TypeScript

import { useContext } from 'react'
import FlagContext from 'components/ui/Flag/FlagContext'
export function useFlag<T = boolean>(name: string) {
const store: any = useContext(FlagContext)
const isObjectEmpty = (objectName: Object) => {
return Object.keys(objectName).length === 0
}
if (!isObjectEmpty(store) && store[name] === undefined) {
console.error(`Flag key "${name}" does not exist in flagStore`)
return false
}
return store[name] as T
}