Repository navigation
Expand file tree
/
Copy pathreact.d.ts
More file actions
40 lines (40 loc) · 1.58 KB
/
Copy pathreact.d.ts
File metadata and controls
40 lines (40 loc) · 1.58 KB
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
33
34
35
36
37
38
39
40
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.ReactNode;
};
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>;
/**
* Resolve an experiment flag for the identified user and record one
* `$flag_exposure` event, but only when the identity is enrolled in a running
* experiment (`flag.experiment.inExperiment`). Returns the flag (or null)
* either way, and never throws when events are disabled.
* @experimental @internal
*/
export declare function useExperiment(featureName: string): IFlagsmithFeature | null;
export declare const useFlagsmith: <F extends string | Record<string, any>,
T extends string = string>() => IFlagsmith<F, T>;
export declare const useFlagsmithLoading: () => LoadingState | undefined;