Skip to content

Commit 71e6425

Browse files
Polishing
1 parent b930e2e commit 71e6425

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

CHANGES.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
- BREAKING CHANGES:
88
- Updated the default value of the `updateOnSdkUpdate` and `updateOnSdkTimedout` parameters of the `useSplitClient` and `useSplitTreatments` hooks options object to `true`, to re-render on all SDK events by default. The same applies for the equivalent props in the `[with]SplitClient` and `[with]SplitTreatments` components.
99
- 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.
10-
- Updated the `SplitFactoryProvider` component to not accept a child as a function (render prop), to avoid unnecessary re-renders when using the library hooks. Refer to ./MIGRATION-GUIDE.md for instructions on how to migrate the child as a function to a regular React element.
10+
- Updated the `SplitFactoryProvider` component to not accept a child as a function (render prop), to avoid unnecessary re-renders when using the library hooks. Refer to ./MIGRATION-GUIDE.md for instructions on how to migrate your component to be passed as a regular React JSX element if you were using this pattern.
1111
- Removed the `core.trafficType` option from the SDK configuration object, and the `trafficType` parameter from the SDK `client()` method, `useSplitClient`, `useTrack`, `withSplitClient` and `SplitClient` component. This is because traffic types can no longer be bound to SDK clients in JavaScript SDK v11.0.0, and so the traffic type must be provided as first argument in the `track` method calls.
1212
- Removed deprecated modules: `SplitFactory` component, `useClient`, `useTreatments` and `useManager` hooks. Refer to ./MIGRATION-GUIDE.md for instructions on how to migrate to the new alternatives.
1313
- Renamed `SplitSdk` to `SplitFactory` function, which is the underlying Split SDK factory, i.e., `import { SplitFactory } from '@splitsoftware/splitio'`.

MIGRATION-GUIDE.md

+17-17
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33

44
React SDK v2.0.0 has a few breaking changes that you should consider when migrating from a previous version. The main changes are:
55

6-
- Deprecated `useClient`, `useTreatments`, and `useManager` hooks have been removed.
6+
- **Deprecated `useClient`, `useTreatments`, and `useManager` hooks have been removed.**
77

88
Follow [this section](#migrating-to-get-react-sdk-v1100-improvements-replacing-the-deprecated-useclient-usetreatments-and-usemanager-hooks) to migrate to the new hooks `useSplitClient`, `useSplitTreatments`, and `useSplitManager` respectively.
99

10-
- Deprecated `SplitFactory` provider has been removed, `withSplitFactory` is deprecated, and `SplitFactoryProvider` doesn't accept `updateOn` props and a render function as children anymore.
10+
- **Deprecated `SplitFactory` provider has been removed, `withSplitFactory` is deprecated, and `SplitFactoryProvider` doesn't accept `updateOn` props and a render function as children anymore.**
1111

1212
To migrate your existing code to the new version of `SplitFactoryProvider`, consider the following refactor example. Replace:
1313

@@ -37,22 +37,22 @@ const App = () => {
3737

3838
// or withSplitFactory
3939
const App = withSplitFactory(mySplitConfig, undefined, DEFAULT_CLIENT_ATTRIBUTES)(
40-
MyComponent, false /* updateOnSdkUpdate */
40+
MyComponent, false /* updateOnSdkUpdate = false */
4141
);
4242
```
4343

4444
with:
4545

4646
```tsx
4747
const MyComponent = () => {
48-
const props: ISplitContextValues = useSplitClient({ updateOnSdkUpdate: false, attributes: DEFAULT_CLIENT_ATTRIBUTES });
48+
const props: ISplitContextValues = useSplitClient({ updateOnSdkUpdate: false });
4949
const { factory, client, isReady, isReadyFromCache, ... } = props;
5050
...
5151
};
5252

5353
const App = () => {
5454
return (
55-
<SplitFactoryProvider config={mySplitConfig} >
55+
<SplitFactoryProvider config={mySplitConfig} attributes={DEFAULT_CLIENT_ATTRIBUTES} >
5656
<MyComponent />
5757
</SplitFactoryProvider>
5858
);
@@ -62,9 +62,9 @@ const App = () => {
6262
Notice that `MyComponent` was refactored to use the `useSplitClient` hook and is passed as a React element rather than a render function as children.
6363
The `useSplitClient` hook is called without providing an `splitKey` param, meaning that the client at the context will be used, i.e., the default client which key is set in the `core.key` property of the `mySplitConfig` object, and the `updateOn` and `attributes` props are passed as options to the hook.
6464

65-
- High-Order-Components (`withSplitClient`, `withSplitTreatments`) and components that accept a render function as child component (`SplitTreatments`, and `SplitClient`) have been deprecated and might be removed in future major releases. The deprecation is intended to simplify the API and discourage the use of old patterns (HOCs and render props) in favor of hook alternatives to take advantage of React optimizations.
65+
- **High-Order-Components (`withSplitClient`, `withSplitTreatments`) and components that accept a render function as child component (`SplitTreatments`, and `SplitClient`) have been deprecated and might be removed in a future major release.**
6666

67-
To migrate your existing code based on `withSplitClient` or `SplitClient`, consider the following refactor using the `useSplitClient` hook. Replace:
67+
The deprecation is intended to simplify the API and discourage the use of old patterns (HOCs and render props) in favor of hook alternatives to take advantage of React optimizations. To migrate your existing code based on `withSplitClient` or `SplitClient`, consider the following refactor using the `useSplitClient` hook. Replace:
6868

6969
```tsx
7070
const MyComponent = (props: ISplitContextValues) => {
@@ -73,16 +73,16 @@ const MyComponent = (props: ISplitContextValues) => {
7373
};
7474

7575
const App = withSplitFactory(mySplitConfig)(
76-
withSplitClient(KEY)(
77-
MyComponent, undefined, undefined, undefined, false /* updateOnSdkReadyFromCache */
76+
withSplitClient(OTHER_KEY, OTHER_KEY_ATTRIBUTES)(
77+
MyComponent, undefined, undefined, undefined, false /* updateOnSdkReadyFromCache = false */
7878
)
7979
);
8080

8181
// or
8282
const App = () => {
8383
return (
8484
<SplitFactory config={mySplitConfig} >
85-
<SplitClient splitKey={KEY} updateOnSdkReadyFromCache={false} >
85+
<SplitClient splitKey={OTHER_KEY} attributes={OTHER_KEY_ATTRIBUTES} updateOnSdkReadyFromCache={false} >
8686
{MyComponent}
8787
</SplitClient>
8888
</SplitFactory>
@@ -94,7 +94,7 @@ with:
9494

9595
```tsx
9696
const MyComponent = () => {
97-
const props: ISplitContextValues = useSplitClient({ splitKey: KEY, updateOnSdkReadyFromCache: false });
97+
const props: ISplitContextValues = useSplitClient({ splitKey: OTHER_KEY, attributes: OTHER_KEY_ATTRIBUTES, updateOnSdkReadyFromCache: false });
9898
const { client, isReady, ... } = props;
9999
...
100100
};
@@ -117,9 +117,9 @@ const MyComponent = (props: ISplitTreatmentsChildProps) => {
117117
};
118118

119119
const App = withSplitFactory(mySplitConfig)(
120-
withSplitClient(KEY)(
120+
withSplitClient(OTHER_KEY)(
121121
withSplitTreatments(FEATURE_FLAG_NAMES, ATTRIBUTES)(
122-
MyComponent, undefined, undefined, undefined, false /* updateOnSdkReadyFromCache */
122+
MyComponent
123123
)
124124
)
125125
);
@@ -128,7 +128,7 @@ const App = withSplitFactory(mySplitConfig)(
128128
const App = () => {
129129
return (
130130
<SplitFactory config={mySplitConfig} >
131-
<SplitClient splitKey={KEY} updateOnSdkReadyFromCache={false} >
131+
<SplitClient splitKey={OTHER_KEY} >
132132
<SplitTreatments names={FEATURE_FLAG_NAMES} attributes={ATTRIBUTES} >
133133
{MyComponent}
134134
</SplitTreatments>
@@ -142,7 +142,7 @@ with:
142142

143143
```tsx
144144
const MyComponent = () => {
145-
const props: ISplitTreatmentsChildProps = useSplitTreatments({ splitKey: KEY, names: FEATURE_FLAG_NAMES, attributes: ATTRIBUTES, updateOnSdkReadyFromCache: false });
145+
const props: ISplitTreatmentsChildProps = useSplitTreatments({ splitKey: OTHER_KEY, names: FEATURE_FLAG_NAMES, attributes: ATTRIBUTES });
146146
const { treatments, isReady, ... } = props;
147147
...
148148
};
@@ -156,7 +156,7 @@ const App = () => {
156156
};
157157
```
158158

159-
- Renamed `SplitSdk` function to `SplitFactory`.
159+
- **Renamed `SplitSdk` function to `SplitFactory`.**
160160

161161
If you are using the `SplitSdk` function to create a factory and pass it to the `SplitFactoryProvider` component, you should rename it to `SplitFactory`. For example:
162162

@@ -190,7 +190,7 @@ const App = () => {
190190
};
191191
```
192192

193-
- Traffic type cannot be bound to SDK clients anymore.
193+
- **Traffic type cannot be bound to SDK clients anymore.**
194194

195195
If you were passing the `trafficType` to the SDK config or the `useSplitClient` or `useTrack` hooks, you should remove it. The `trafficType` is now required to be passed as initial argument of the `track` method. For example:
196196

0 commit comments

Comments
 (0)