Skip to content

Commit 4b6a28d

Browse files
Polishing
1 parent 71e6425 commit 4b6a28d

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

MIGRATION-GUIDE.md

+11-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
# Migrating to React SDK v2.0.0:
2+
# Migrating to React SDK v2.0.0
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

@@ -9,7 +9,7 @@ Follow [this section](#migrating-to-get-react-sdk-v1100-improvements-replacing-t
99

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

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

1414
```tsx
1515
const MyComponent = (props: ISplitContextValues) => {
@@ -41,7 +41,7 @@ const App = withSplitFactory(mySplitConfig, undefined, DEFAULT_CLIENT_ATTRIBUTES
4141
);
4242
```
4343

44-
with:
44+
should be refactored to:
4545

4646
```tsx
4747
const MyComponent = () => {
@@ -59,12 +59,14 @@ const App = () => {
5959
};
6060
```
6161

62-
Notice that `MyComponent` was refactored to use the `useSplitClient` hook and is passed as a React element rather than a render function as children.
63-
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.
62+
Notice that `MyComponent` was refactored to use the `useSplitClient` hook and is passed as a React JSX element rather than a render function.
63+
The `useSplitClient` hook is called without providing an `splitKey` param, meaning that the default client, which key is set in the `core.key` property of the `mySplitConfig` object, will be used, and the `updateOn` and `attributes` props are passed as options to the hook.
6464

6565
- **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-
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:
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.
68+
69+
To migrate your existing code based on `withSplitClient` or `SplitClient`, consider the following refactor using the `useSplitClient` hook:
6870

6971
```tsx
7072
const MyComponent = (props: ISplitContextValues) => {
@@ -90,7 +92,7 @@ const App = () => {
9092
};
9193
```
9294

93-
with:
95+
should be refactored to:
9496

9597
```tsx
9698
const MyComponent = () => {
@@ -108,7 +110,7 @@ const App = () => {
108110
};
109111
```
110112

111-
To migrate your existing code based on `withSplitTreatments` or `SplitTreatments`, consider the following refactor using the `useSplitTreatments` hook. Replace:
113+
To migrate your existing code based on `withSplitTreatments` or `SplitTreatments`, consider the following refactor using the `useSplitTreatments` hook:
112114

113115
```tsx
114116
const MyComponent = (props: ISplitTreatmentsChildProps) => {
@@ -138,7 +140,7 @@ const App = () => {
138140
};
139141
```
140142

141-
with:
143+
should be refactored to:
142144

143145
```tsx
144146
const MyComponent = () => {

0 commit comments

Comments
 (0)