UNPKG

@splitsoftware/splitio-react

Version:

A React library to easily integrate and use Split JS SDK

27 lines (26 loc) 1.49 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.withSplitTreatments = void 0; var tslib_1 = require("tslib"); var React = (0, tslib_1.__importStar)(require("react")); var SplitTreatments_1 = require("./SplitTreatments"); /** * High-Order Component for SplitTreatments. * The wrapped component receives all the props of the container, * along with the passed props from SplitTreatments (see ISplitTreatmentsChildProps). * * @param names - list of feature flag names * @param attributes - An object of type Attributes used to evaluate the feature flags. * * @deprecated `withSplitTreatments` will be removed in a future major release. We recommend replacing it with the `useSplitTreatments` hook. */ function withSplitTreatments(names, attributes) { return function withSplitTreatmentsHoc(WrappedComponent, updateOnSdkUpdate, updateOnSdkTimedout, updateOnSdkReady, updateOnSdkReadyFromCache) { return function wrapper(props) { return (React.createElement(SplitTreatments_1.SplitTreatments, { names: names, updateOnSdkUpdate: updateOnSdkUpdate, updateOnSdkTimedout: updateOnSdkTimedout, updateOnSdkReady: updateOnSdkReady, updateOnSdkReadyFromCache: updateOnSdkReadyFromCache, attributes: attributes }, function (splitProps) { return (React.createElement(WrappedComponent, (0, tslib_1.__assign)({}, props, splitProps))); })); }; }; } exports.withSplitTreatments = withSplitTreatments;