UNPKG

voicebot-react-native-expo

Version:

This is a voicebot-react-native package of Kipps AI voice bot for React Native Expo

29 lines (24 loc) 687 B
import * as React from 'react'; /** @internal */ export interface FeatureFlags { autoSubscription?: boolean; } type FeatureContext<T extends boolean = false> = T extends true ? FeatureFlags : FeatureFlags | undefined; /** @internal */ export const LKFeatureContext = React.createContext<FeatureFlags | undefined>(undefined); /** * @internal */ export function useFeatureContext<T extends boolean>(require?: T): FeatureContext<T> { const ctx = React.useContext(LKFeatureContext) as FeatureContext<T>; if (require === true) { if (ctx) { return ctx; } else { throw Error('tried to access feature context, but none is present'); } } return ctx; }