@splitsoftware/splitio-react
Version:
A React library to easily integrate and use Split JS SDK
24 lines (23 loc) • 1.12 kB
JavaScript
import { __assign } from "tslib";
import { useSplitClient } from './useSplitClient';
import { useSplitContext } from './SplitContext';
/**
* `useSplitManager` is a hook that returns an Split Context object with the manager instance from the Split factory.
*
* @returns A Split Context object merged with the manager and its status.
*
* @example
* ```js
* const { manager, isReady, isReadyFromCache, lastUpdate, ... } = useSplitManager();
* ```
*
* @see {@link https://help.split.io/hc/en-us/articles/360020448791-JavaScript-SDK#manager}
*/
export function useSplitManager() {
// @TODO refactor next lines to `const context = useSplitClient();` when `SplitClient` is removed
// This is required to avoid retrieving the status of a non-default client if context was updated by a `SplitClient` component.
var factory = useSplitContext().factory;
var context = useSplitClient({ splitKey: factory === null || factory === void 0 ? void 0 : factory.settings.core.key });
var manager = factory ? factory.manager() : undefined;
return __assign(__assign({}, context), { manager: manager });
}