From 8b7b2bbed6ceae47714b4f2e478e0aa061b29b33 Mon Sep 17 00:00:00 2001 From: Emiliano Sanchez Date: Wed, 15 Nov 2023 17:38:16 -0300 Subject: [PATCH 1/3] Export missing types --- src/__tests__/index.test.ts | 5 ++++- src/index.ts | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/__tests__/index.test.ts b/src/__tests__/index.test.ts index 3604c01..c8bd2f3 100644 --- a/src/__tests__/index.test.ts +++ b/src/__tests__/index.test.ts @@ -16,6 +16,7 @@ import { useSplitTreatments as exportedUseSplitTreatments, useSplitManager as exportedUseSplitManager, // Checks that types are exported. Otherwise, the test would fail with a TS error. + GetTreatmentsOptions, ISplitClientChildProps, ISplitClientProps, ISplitContextValues, @@ -24,7 +25,9 @@ import { ISplitStatus, ISplitTreatmentsChildProps, ISplitTreatmentsProps, - IUpdateProps + IUpdateProps, + IUseSplitClientOptions, + IUseSplitTreatmentsOptions, } from '../index'; import { SplitContext } from '../SplitContext'; import { SplitFactory as SplitioEntrypoint } from '@splitsoftware/splitio/client'; diff --git a/src/index.ts b/src/index.ts index 6aff505..f25e6fb 100644 --- a/src/index.ts +++ b/src/index.ts @@ -25,6 +25,7 @@ export { SplitContext } from './SplitContext'; // Types export type { + GetTreatmentsOptions, ISplitClientChildProps, ISplitClientProps, ISplitContextValues, @@ -33,5 +34,7 @@ export type { ISplitStatus, ISplitTreatmentsChildProps, ISplitTreatmentsProps, - IUpdateProps + IUpdateProps, + IUseSplitClientOptions, + IUseSplitTreatmentsOptions, } from './types'; From 44cf2cce4b5217a7513ed91fae94695de0fe116e Mon Sep 17 00:00:00 2001 From: Emiliano Sanchez Date: Wed, 15 Nov 2023 17:52:15 -0300 Subject: [PATCH 2/3] Update comments --- src/types.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/types.ts b/src/types.ts index 81b735e..83d4b26 100644 --- a/src/types.ts +++ b/src/types.ts @@ -193,8 +193,8 @@ export type GetTreatmentsOptions = ({ } /** - * useSplitTreatments options interface. This is the options object accepted by useSplitTreatments hook, - * used to call 'client.getTreatmentsWithConfig()', or 'client.getTreatmentsWithConfigByFlagSets()', and retrieve the result together with the Split context. + * useSplitTreatments options interface. This is the options object accepted by useSplitTreatments hook, used to call 'client.getTreatmentsWithConfig()', or 'client.getTreatmentsWithConfigByFlagSets()', + * depending on whether `names` or `flagSets` options are provided, and to retrieve the result along with the Split context. */ export type IUseSplitTreatmentsOptions = GetTreatmentsOptions & IUseSplitClientOptions; @@ -206,17 +206,20 @@ export interface ISplitTreatmentsChildProps extends ISplitContextValues { /** * An object with the treatments with configs for a bulk of feature flags, returned by client.getTreatmentsWithConfig(). * Each existing configuration is a stringified version of the JSON you defined on the Split user interface. For example: + * + * ```js * { - * feature1: { treatment: 'on', config: null } + * feature1: { treatment: 'on', config: null }, * feature2: { treatment: 'off', config: '{"bannerText":"Click here."}' } * } + * ``` */ treatments: SplitIO.TreatmentsWithConfig; } /** - * SplitTreatments Props interface. These are the props accepted by SplitTreatments component, - * used to call 'client.getTreatmentsWithConfig()', or 'client.getTreatmentsWithConfigByFlagSets()', and pass the result to the child component. + * SplitTreatments Props interface. These are the props accepted by SplitTreatments component, used to call 'client.getTreatmentsWithConfig()', or 'client.getTreatmentsWithConfigByFlagSets()', + * depending on whether `names` or `flagSets` props are provided, and to pass the result to the child component. */ export type ISplitTreatmentsProps = GetTreatmentsOptions & { From 1f370c2cddb8a5a005f721878833bddbbcd02ede Mon Sep 17 00:00:00 2001 From: Emiliano Sanchez Date: Thu, 16 Nov 2023 11:34:11 -0300 Subject: [PATCH 3/3] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f936823..a171ed1 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ This SDK is designed to work with Split, the platform for controlled rollouts, w This SDK is compatible with React 16.3.0 and above, since it uses [React Context API](https://reactjs.org/docs/context.html). -Some features, such as `useClient` and `useManager`, use [React Hooks API](https://reactjs.org/docs/hooks-overview.html) that requires React 16.8.0 or later. +Some features, such as `useSplitClient` and `useSplitTreatments`, use [React Hooks API](https://reactjs.org/docs/hooks-overview.html) that requires React 16.8.0 or later. ## Getting started Below is a simple example that describes the instantiation and most basic usage of our SDK: