UNPKG

feature-flip

Version:

Flexible React & React Native feature flagging/flipping/toggling for simple use cases

40 lines (37 loc) 1.95 kB
import { ReactNode } from 'react'; declare type Value = boolean | string | string[]; declare type FeatureFlips = { [name: string]: Value | FeatureFlips; }; declare type FeatureFlipsConfig = { onParseValue?: (value: any) => boolean; seperator?: RegExp | string; }; declare const defaultValueParser: (value: any) => boolean; declare const useFeatureFlips: () => { config?: FeatureFlipsConfig | undefined; featureFlips?: FeatureFlips | undefined; }; declare const useFeatureFlip: (name: string, fallback?: boolean) => any; declare type FeatureFlipsProviderProps = { value: FeatureFlips; children: ReactNode; config?: FeatureFlipsConfig; }; declare const FeatureFlipsProvider: ({ value: featureFlips, config, children, }: FeatureFlipsProviderProps) => JSX.Element; declare type FeatureFlipProps = { name: string; children: ReactNode | ((isOn: boolean) => JSX.Element); fallback?: ReactNode; }; declare const FeatureFlip: ({ name, children, fallback, }: FeatureFlipProps) => JSX.Element; declare const withFeatureFlip: (name: string, fallback?: ReactNode | null) => (WrappedComponent: any) => (props: any) => JSX.Element; declare const Provider: ({ value: featureFlips, config, children, }: FeatureFlipsProviderProps) => JSX.Element; declare const withFeature: (name: string, fallback?: ReactNode | null) => (WrappedComponent: any) => (props: any) => JSX.Element; declare const useFeature: (name: string, fallback?: boolean) => any; declare const useFeatures: () => { config?: FeatureFlipsConfig | undefined; featureFlips?: FeatureFlips | undefined; }; declare const Feature: ({ name, children, fallback, }: FeatureFlipProps) => JSX.Element; export { Feature, FeatureFlip, FeatureFlipProps, FeatureFlips, FeatureFlipsConfig, FeatureFlipsProvider, FeatureFlipsProviderProps, Provider, Value, defaultValueParser, useFeature, useFeatureFlip, useFeatureFlips, useFeatures, withFeature, withFeatureFlip };