@splitsoftware/splitio-react
Version:
A React library to easily integrate and use Split JS SDK
17 lines (16 loc) • 1.15 kB
TypeScript
import { IUseTreatmentWithConfigResult, IUseTreatmentOptions } from './types';
/**
* `useTreatmentWithConfig` 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.getTreatmentWithConfig()` 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 TreatmentWithConfig 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: { treatment, config }, isReady, isReadyFromCache, hasTimedout, lastUpdate, ... } = useTreatmentWithConfig({ name: 'feature_1'});
* ```
*
* @see {@link https://developer.harness.io/docs/feature-management-experimentation/sdks-and-infrastructure/client-side-sdks/javascript-sdk/#get-treatments-with-configurations}
*/
export declare function useTreatmentWithConfig(options: IUseTreatmentOptions): IUseTreatmentWithConfigResult;