Skip to content

Commit 0b869f9

Browse files
Update deprecation comment to add more info
1 parent 326aa6d commit 0b869f9

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/SplitFactory.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@ import { DEFAULT_UPDATE_OPTIONS } from './useSplitClient';
1414
* The underlying SDK factory and client is set on the constructor, and cannot be changed during the component lifecycle,
1515
* even if the component is updated with a different config or factory prop.
1616
*
17-
* @see {@link https://help.split.io/hc/en-us/articles/360020448791-JavaScript-SDK}
18-
*
1917
* @deprecated Replace with the new `SplitFactoryProvider` component.
18+
* `SplitFactoryProvider` is a drop-in replacement that properly handles side effects (factory creation and destruction) within the React component lifecycle, avoiding issues with factory recreation and memory leaks.
19+
* Note: There is a subtle breaking change in `SplitFactoryProvider`. When using the `config` prop, `factory` and `client` properties in the context are `null` in the first render, until the context is updated when the factory is ready. This differs from the previous behavior where `factory` and `client` were immediately available.
20+
*
21+
* @see {@link https://help.split.io/hc/en-us/articles/360038825091-React-SDK#2-instantiate-the-sdk-and-create-a-new-split-client}
2022
*/
2123
export class SplitFactory extends React.Component<ISplitFactoryProps, { factory: SplitIO.IBrowserSDK | null, client: SplitIO.IBrowserClient | null }> {
2224

src/withSplitFactory.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import { SplitFactory } from './SplitFactory';
1111
* @param factory Split factory instance to use instead of creating a new one with the config object.
1212
*
1313
* @deprecated Use `SplitFactoryProvider` instead.
14+
* `SplitFactoryProvider` is a drop-in replacement of `SplitFactory` that properly handles side effects (factory creation and destruction) within the React component lifecycle, avoiding issues with factory recreation and memory leaks.
15+
* Note: There is a subtle breaking change in `SplitFactoryProvider`. When using the `config` prop, `factory` and `client` properties in the context are `null` in the first render, until the context is updated when the factory is ready. This differs from the previous behavior where `factory` and `client` were immediately available.
1416
*/
1517
export function withSplitFactory(config?: SplitIO.IBrowserSettings, factory?: SplitIO.IBrowserSDK, attributes?: SplitIO.Attributes) {
1618

0 commit comments

Comments
 (0)