1.0.3 • Published 3 years ago
@firstkind/react v1.0.3
First Kind React SDK
This SDK facilitates using the client APIs provided by First Kind Software
Install
npm i @firstkind/react
Usage
import { useFetchFlag } from "@firstkind/react";
import React from "react";
const LoadPage: React.FC = () => {
const { isLoading, result } = await useFetchFlag({
apiKey: "pk_FpACzwidBsbDiaqPloKnCfESozthonuuLbGYSLvb",
userId: "u-1234",
projectKey: "example-app",
environmentKey: "development",
flagKey: "show-new-loading-screen",
defaultValue: false,
});
if (isLoading) {
return <div>Loading</div>;
}
return result ? <div>new menu</div> : <div>old menu</div>;
};
Types
This library comes with typescript types.
import { FetchFlagArgs, FetchFlagsArgs } from "@firstkind/sdk";
export declare const useFetchFlag: <T>({
apiKey,
environmentKey,
flagKey,
projectKey,
cacheDuration,
defaultValue,
useCache,
userId,
}: FetchFlagArgs<T>) => {
isLoading: boolean;
result: T | undefined;
refetch: () => Promise<void>;
};
export declare const useFetchFlags: <T>({
apiKey,
environmentKey,
flagKeys,
projectKey,
cacheDuration,
defaultValue,
useCache,
userId,
resolveRemotely,
}: FetchFlagsArgs<T>) => {
isLoading: boolean;
result:
| {
[key: string]: any;
}
| undefined;
refetch: () => Promise<void>;
};