You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGES.txt
+3
Original file line number
Diff line number
Diff line change
@@ -1,3 +1,6 @@
1
+
2.1.1 (April 8, 2025)
2
+
- Bugfixing - Fixed `useSplitClient` and `useSplitTreatments` hooks to properly respect `updateOn<Event>` options. Previously, if the hooks were re-called due to a component re-render, they used the latest version of the SDK client status ignoring when `updateOn<Event>` options were set to `false` and resulting in unexpected changes in treatment values.
3
+
1
4
2.1.0 (March 28, 2025)
2
5
- Added a new optional `properties` argument to the options object of the `useSplitTreatments` hook, allowing to pass a map of properties to append to the generated impressions sent to Split backend. Read more in our docs.
3
6
- Updated @splitsoftware/splitio package to version 11.2.0 that includes some minor updates:
@@ -96,4 +97,4 @@ For a comprehensive list of open source projects visit our [Github page](https:/
96
97
97
98
**Learn more about Split:**
98
99
99
-
Visit [split.io/product](https://www.split.io/product) for an overview of Split, or visit our documentation at [help.split.io](http://help.split.io) for more detailed information.
100
+
Visit [split.io/product](https://www.split.io/product) for an overview of Split, or visit our documentation at [help.split.io](https://help.split.io) for more detailed information.
Copy file name to clipboardExpand all lines: src/__tests__/SplitTreatments.test.tsx
+25-12
Original file line number
Diff line number
Diff line change
@@ -200,36 +200,37 @@ let renderTimes = 0;
200
200
* Tests for asserting that client.getTreatmentsWithConfig and client.getTreatmentsWithConfigByFlagSets are not called unnecessarily when using SplitTreatments and useSplitTreatments.
// Updates were batched as a single render, due to automatic batching https://reactjs.org/blog/2022/03/29/react-v18.html#new-feature-automatic-batching
it('rerenders and does not re-evaluate feature flags if lastUpdate timestamp does not change (e.g., SDK_UPDATE event but `updateOnSdkUpdate` false).',()=>{
act(()=>mainClient.__emitter__.emit(Event.SDK_UPDATE));// do not trigger re-render because updateOnSdkUpdate is false now
261
+
act(()=>mainClient.__emitter__.emit(Event.SDK_UPDATE));// do not trigger re-render because updateOnSdkUpdate is false
231
262
expect(rendersCount).toBe(5);
263
+
264
+
wrapper.rerender(<ComponentupdateOnSdkUpdate={false}updateOnSdkTimedout={false}/>);// should not update the status (SDK_UPDATE event should be ignored)
265
+
expect(rendersCount).toBe(6);
266
+
expect(currentStatus).toEqual(previousStatus);
267
+
268
+
wrapper.rerender(<ComponentupdateOnSdkUpdate={null/** invalid type should default to `true` */}/>);// trigger re-render and update the status because updateOnSdkUpdate is true and there was an SDK_UPDATE event
Copy file name to clipboardExpand all lines: src/useSplitClient.ts
+9-4
Original file line number
Diff line number
Diff line change
@@ -31,14 +31,16 @@ export function useSplitClient(options?: IUseSplitClientOptions): ISplitContextV
31
31
constcontext=useSplitContext();
32
32
const{client: contextClient, factory }=context;
33
33
34
-
// @TODO Move `getSplitClient` side effects
34
+
// @TODO Move `getSplitClient` side effects and reduce the function cognitive complexity
35
35
// @TODO Once `SplitClient` is removed, which updates the context, simplify next line as `const client = factory ? getSplitClient(factory, splitKey) : undefined;`
0 commit comments