-
Notifications
You must be signed in to change notification settings - Fork 42
/
Copy pathreact.d.ts
32 lines (32 loc) · 1.21 KB
/
react.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import React, { FC } from 'react';
import { IFlagsmith, IFlagsmithTrait, IFlagsmithFeature, IState, LoadingState } from './types';
export * from './types';
export declare const FlagsmithContext: React.Context<IFlagsmith>;
export declare type FlagsmithContextType<F extends string = string, T extends string = string> = {
flagsmith: IFlagsmith<F, T>;
options?: Parameters<IFlagsmith<F, T>['init']>[0];
serverState?: IState;
children: React.ReactElement[] | React.ReactElement;
};
type UseFlagsReturn<
F extends string | Record<string, any>,
T extends string
> = F extends string
? {
[K in F]: IFlagsmithFeature;
} & {
[K in T]: IFlagsmithTrait;
}
: {
[K in keyof F]: IFlagsmithFeature<F[K]>;
} & {
[K in T]: IFlagsmithTrait;
};
export declare const FlagsmithProvider: FC<FlagsmithContextType>;
export declare function useFlags<
F extends string | Record<string, any>,
T extends string = string
>(_flags: readonly (F | keyof F)[], _traits?: readonly T[]): UseFlagsReturn<F, T>;
export declare const useFlagsmith: <F extends string | Record<string, any>,
T extends string = string>() => IFlagsmith<F, T>;
export declare const useFlagsmithLoading: () => LoadingState | undefined;