diff --git a/CHANGES.txt b/CHANGES.txt index b800f1f..6b2a74b 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,9 +1,11 @@ 2.0.0 (October XX, 2024) - Added support for targeting rules based on large segments for browsers. + - Added the `useSplitContext` hook to access the Split context value directly, although it should probably not be used frequently. - Updated @splitsoftware/splitio package to version 10.29.0 that includes minor updates, and updated some transitive dependencies for vulnerability fixes. - Renamed distribution folders from `/lib` to `/cjs` for CommonJS build, and `/es` to `/esm` for EcmaScript Modules build. - BREAKING CHANGES: - Updated error handling: using the library modules without wrapping them in a `SplitFactoryProvider` component will now throw an error instead of logging it, as the modules requires the `SplitContext` to work properly. + - Removed the export of the `SplitContext` object from the library index. The Split context value can be retrieved with the `useSplitContext` hook. - Removed deprecated modules: `SplitFactory` component, `useClient`, `useTreatments` and `useManager` hooks, and `withSplitFactory`, `withSplitClient` and `withSplitTreatments` high-order components. Refer to ./MIGRATION-GUIDE.md for instructions on how to migrate to the new alternatives. - Renamed TypeScript interfaces `ISplitFactoryProps` to `ISplitFactoryProviderProps`, and `ISplitFactoryChildProps` to `ISplitFactoryProviderChildProps`. - Renamed `SplitSdk` to `SplitFactory` function, which is the underlying Split SDK factory, i.e., `import { SplitFactory } from '@splitsoftware/splitio'`. diff --git a/src/__tests__/index.test.ts b/src/__tests__/index.test.ts index d8efd44..b748c41 100644 --- a/src/__tests__/index.test.ts +++ b/src/__tests__/index.test.ts @@ -1,6 +1,5 @@ /* eslint-disable @typescript-eslint/no-unused-vars */ import { - SplitContext as ExportedSplitContext, SplitFactory as ExportedSplitFactory, SplitFactoryProvider as ExportedSplitFactoryProvider, SplitClient as ExportedSplitClient, @@ -9,6 +8,7 @@ import { useSplitClient as exportedUseSplitClient, useSplitTreatments as exportedUseSplitTreatments, useSplitManager as exportedUseSplitManager, + useSplitContext as exportedUseSplitContext, // Checks that types are exported. Otherwise, the test would fail with a TS error. GetTreatmentsOptions, ISplitClientChildProps, @@ -23,7 +23,6 @@ import { IUseSplitClientOptions, IUseSplitTreatmentsOptions, } from '../index'; -import { SplitContext } from '../SplitContext'; import { SplitFactory } from '@splitsoftware/splitio/client'; import { SplitFactoryProvider } from '../SplitFactoryProvider'; import { SplitClient } from '../SplitClient'; @@ -32,6 +31,7 @@ import { useTrack } from '../useTrack'; import { useSplitClient } from '../useSplitClient'; import { useSplitTreatments } from '../useSplitTreatments'; import { useSplitManager } from '../useSplitManager'; +import { useSplitContext } from '../SplitContext'; describe('index', () => { @@ -46,10 +46,7 @@ describe('index', () => { expect(exportedUseSplitClient).toBe(useSplitClient); expect(exportedUseSplitTreatments).toBe(useSplitTreatments); expect(exportedUseSplitManager).toBe(useSplitManager); - }); - - it('should export SplitContext', () => { - expect(ExportedSplitContext).toBe(SplitContext); + expect(exportedUseSplitContext).toBe(useSplitContext); }); it('should export SplitFactory', () => { diff --git a/src/index.ts b/src/index.ts index d4c45f7..e47ec43 100644 --- a/src/index.ts +++ b/src/index.ts @@ -11,9 +11,7 @@ export { useTrack } from './useTrack'; export { useSplitClient } from './useSplitClient'; export { useSplitTreatments } from './useSplitTreatments'; export { useSplitManager } from './useSplitManager'; - -// SplitContext -export { SplitContext } from './SplitContext'; +export { useSplitContext } from './SplitContext'; // Types export type { diff --git a/umd.ts b/umd.ts index 3ce942a..bb3e07c 100644 --- a/umd.ts +++ b/umd.ts @@ -2,12 +2,12 @@ import { SplitFactory, SplitFactoryProvider, SplitClient, SplitTreatments, useSplitClient, useSplitTreatments, useTrack, useSplitManager, - SplitContext, + useSplitContext, } from './src/index'; export default { SplitFactory, SplitFactoryProvider, SplitClient, SplitTreatments, useSplitClient, useSplitTreatments, useTrack, useSplitManager, - SplitContext, + useSplitContext, };