UNPKG

@splitsoftware/splitio-react

Version:

A React library to easily integrate and use Split JS SDK

30 lines (29 loc) 1.79 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.withSplitFactory = void 0; var tslib_1 = require("tslib"); var React = (0, tslib_1.__importStar)(require("react")); var SplitFactoryProvider_1 = require("./SplitFactoryProvider"); var SplitClient_1 = require("./SplitClient"); /** * High-Order Component for `SplitFactoryProvider`. * The wrapped component receives all the props of the container, * along with the passed props from the Split context (see `ISplitFactoryChildProps`). * * @param config - Config object used to instantiate a Split factory * @param factory - Split factory instance to use instead of creating a new one with the config object. * @param attributes - An object of type Attributes used to evaluate the feature flags. * * @deprecated `withSplitFactory` will be removed in a future major release. We recommend replacing it with the `SplitFactoryProvider` component. */ function withSplitFactory(config, factory, attributes) { return function withSplitFactoryHoc(WrappedComponent, updateOnSdkUpdate, updateOnSdkTimedout, updateOnSdkReady, updateOnSdkReadyFromCache) { return function wrapper(props) { return (React.createElement(SplitFactoryProvider_1.SplitFactoryProvider, { config: config, factory: factory }, React.createElement(SplitClient_1.SplitClient, { updateOnSdkUpdate: updateOnSdkUpdate, updateOnSdkTimedout: updateOnSdkTimedout, updateOnSdkReady: updateOnSdkReady, updateOnSdkReadyFromCache: updateOnSdkReadyFromCache, attributes: attributes }, function (splitProps) { return (React.createElement(WrappedComponent, (0, tslib_1.__assign)({}, props, splitProps))); }))); }; }; } exports.withSplitFactory = withSplitFactory;