Skip to content

Commit d7ae0d5

Browse files
Merge pull request #170 from splitio/development
Release v1.10.0
2 parents bb83870 + 67d8c29 commit d7ae0d5

51 files changed

Lines changed: 1782 additions & 1747 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.eslintrc.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ module.exports = {
77
'extends': [
88
'eslint:recommended',
99
'plugin:react/recommended',
10-
'plugin:@typescript-eslint/recommended'
10+
'plugin:@typescript-eslint/recommended',
11+
'plugin:react-hooks/recommended'
1112
],
1213
'parser': '@typescript-eslint/parser',
1314
'parserOptions': {
@@ -28,7 +29,7 @@ module.exports = {
2829
'eol-last': ['error', 'always'],
2930
'keyword-spacing': 'error',
3031
'no-trailing-spaces': 'error',
31-
'space-before-function-paren': ['error', {'named': 'never'}],
32+
'space-before-function-paren': ['error', { 'named': 'never' }],
3233
'react/display-name': 'off',
3334
'@typescript-eslint/no-empty-function': 'off',
3435
'@typescript-eslint/no-inferrable-types': 'off',
@@ -39,6 +40,11 @@ module.exports = {
3940
'destructuring': 'all'
4041
}]
4142
},
43+
'settings': {
44+
'react': {
45+
'version': '16.3.0' // minimum supported version of React
46+
}
47+
},
4248
'overrides': [{
4349
'files': ['src/**/*.ts', 'src/**/*.tsx'],
4450
'excludedFiles': ['src/**/__tests__/**'],
@@ -52,7 +58,7 @@ module.exports = {
5258
},
5359
'rules': {
5460
'no-restricted-syntax': ['error', 'ForOfStatement', 'ForInStatement'],
55-
'compat/compat': ['error', 'defaults, not ie < 11'],
61+
'compat/compat': ['error', 'defaults, ie 11'],
5662
'no-throw-literal': 'error',
5763
'import/no-self-import': 'error',
5864
'import/no-default-export': 'error',

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
run: npm run test -- --coverage
4444

4545
- name: npm build
46-
run: BUILD_BRANCH=$(echo "${GITHUB_REF#refs/heads/}") BUILD_COMMIT=${{ github.sha }} npm run build
46+
run: BUILD_BRANCH=$(echo "${GITHUB_REF#refs/heads/}") npm run build
4747

4848
- name: Set VERSION env
4949
run: echo "VERSION=$(cat package.json | jq -r .version)" >> $GITHUB_ENV

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@
44
/lib
55
/es
66
/umd
7+
/types
78
/coverage
89
.scannerwork

CHANGES.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
1.10.0 (November 16, 2023)
2+
- Added support for Flag Sets on the SDK, which enables grouping feature flags and interacting with the group rather than individually (more details in our documentation):
3+
- Added a new `flagSets` prop to the `SplitTreatments` component and `flagSets` option to the `useSplitTreatments` hook options object, to support evaluating flags in given flag set/s. Either `names` or `flagSets` must be provided to the component and hook. If both are provided, `names` will be used.
4+
- Added a new optional Split Filter configuration option. This allows the SDK and Split services to only synchronize the flags in the specified flag sets, avoiding unused or unwanted flags from being synced on the SDK instance, bringing all the benefits from a reduced payload.
5+
- Added `sets` property to the `SplitView` object returned by the `split` and `splits` methods of the SDK manager to expose flag sets on flag views.
6+
- Added new `useSplitClient`, `useSplitTreatments` and `useSplitManager` hooks as replacements for the now deprecated `useClient`, `useTreatments` and `useManager` hooks.
7+
- These new hooks return the Split context object along with the SDK client, treatments and manager respectively, enabling direct access to status properties like `isReady`, eliminating the need for using the `useContext` hook or the client's `ready` promise.
8+
- `useSplitClient` and `useSplitTreatments` accept an options object as parameter, which support the same arguments as their predecessors, with additional boolean options for controlling re-rendering: `updateOnSdkReady`, `updateOnSdkReadyFromCache`, `updateOnSdkTimedout`, and `updateOnSdkUpdate`.
9+
- `useSplitTreatments` optimizes feature flag evaluations by using the `useMemo` hook to memoize `getTreatmentsWithConfig` method calls from the SDK. This avoids re-evaluating feature flags when the hook is called with the same options and the feature flag definitions have not changed.
10+
- They fixed a bug in the deprecated `useClient` and `useTreatments` hooks, which caused them to not re-render and re-evaluate feature flags when they access a different SDK client than the context and its status updates (i.e., when it emits SDK_READY or other event).
11+
- Added TypeScript types and interfaces to the library index exports, allowing them to be imported from the library index, e.g., `import type { ISplitFactoryProps } from '@splitsoftware/splitio-react'` (Related to issue https://github.com/splitio/react-client/issues/162).
12+
- Updated type declarations of the library components to not restrict the type of the `children` prop to ReactElement, allowing to pass any valid ReactNode value (Related to issue https://github.com/splitio/react-client/issues/164).
13+
- Updated linter and other dependencies for vulnerability fixes.
14+
- Bugfixing - Removed conditional code within hooks to adhere to the rules of hooks and prevent React warnings. Previously, this code checked for the availability of the hooks API (available in React version 16.8.0 or above) and logged an error message. Now, using hooks with React versions below 16.8.0 will throw an error.
15+
- Bugfixing - Updated `useClient` and `useTreatments` hooks to re-render and re-evaluate feature flags when they consume a different SDK client than the context and its status updates (i.e., when it emits SDK_READY or other event).
16+
117
1.9.0 (July 18, 2023)
218
- Updated some transitive dependencies for vulnerability fixes.
319
- Updated @splitsoftware/splitio package to version 10.23.0 that includes:

README.md

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ This SDK is designed to work with Split, the platform for controlled rollouts, w
1111

1212
This SDK is compatible with React 16.3.0 and above, since it uses [React Context API](https://reactjs.org/docs/context.html).
1313

14-
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.
14+
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.
1515

1616
## Getting started
1717
Below is a simple example that describes the instantiation and most basic usage of our SDK:
@@ -20,7 +20,7 @@ Below is a simple example that describes the instantiation and most basic usage
2020
import React from 'react';
2121

2222
// Import SDK functions
23-
import { SplitFactory, SplitTreatments } from '@splitsoftware/splitio-react';
23+
import { SplitFactory, useSplitTreatments } from '@splitsoftware/splitio-react';
2424

2525
// Define your config object
2626
const CONFIG = {
@@ -30,25 +30,27 @@ const CONFIG = {
3030
}
3131
};
3232

33-
function MyReactComponent() {
33+
function MyComponent() {
34+
// Evaluate feature flags with useSplitTreatments hook
35+
const { treatments: { FEATURE_FLAG_NAME }, isReady } = useSplitTreatments({ names: ['FEATURE_FLAG_NAME'] });
36+
37+
// Check SDK readiness using isReady prop
38+
if (!isReady) return <div>Loading SDK ...</div>;
39+
40+
if (FEATURE_FLAG_NAME.treatment === 'on') {
41+
// return JSX for on treatment
42+
} else if (FEATURE_FLAG_NAME.treatment === 'off') {
43+
// return JSX for off treatment
44+
} else {
45+
// return JSX for control treatment
46+
};
47+
}
48+
49+
function MyApp() {
3450
return (
35-
/* Use SplitFactory to instantiate the SDK and makes it available to nested components */
51+
// Use SplitFactory to instantiate the SDK and makes it available to nested components
3652
<SplitFactory config={CONFIG} >
37-
{/* Evaluate feature flags with SplitTreatments component */}
38-
<SplitTreatments names={['FEATURE_FLAG_NAME']} >
39-
{({ treatments: { FEATURE_FLAG_NAME }, isReady }) => {
40-
// Check SDK readiness using isReady prop
41-
if (!isReady)
42-
return <div>Loading SDK ...</div>;
43-
if (FEATURE_FLAG_NAME.treatment === 'on') {
44-
// return JSX for on treatment
45-
} else if (FEATURE_FLAG_NAME.treatment === 'off') {
46-
// return JSX for off treatment
47-
} else {
48-
// return JSX for control treatment
49-
}
50-
}}
51-
</SplitTreatments>
53+
<MyComponent />
5254
</SplitFactory>
5355
);
5456
}

0 commit comments

Comments
 (0)