@splitsoftware/splitio-react
Version:
A React library to easily integrate and use Split JS SDK
17 lines (16 loc) • 1.05 kB
TypeScript
import { IUseTreatmentResult, IUseTreatmentOptions } from './types';
/**
* `useTreatment` is a hook that returns an Split Context object extended with a `treatment` property.
* It uses the `useSplitClient` hook to access the client, and invokes the `client.getTreatment()` method.
*
* @param options - An options object with a feature flag name to evaluate, and an optional `attributes` and `splitKey` values to configure the client.
* @returns A Split Context object extended with a Treatment instance, that might be a control treatment if the client is not available or ready, or if the provided feature flag name does not exist.
*
* @example
* ```js
* const { treatment, isReady, isReadyFromCache, hasTimedout, lastUpdate, ... } = useTreatment({ name: 'feature_1'});
* ```
*
* @see {@link https://developer.harness.io/docs/feature-management-experimentation/sdks-and-infrastructure/client-side-sdks/javascript-sdk/#multiple-evaluations-at-once}
*/
export declare function useTreatment(options: IUseTreatmentOptions): IUseTreatmentResult;