-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathSplitTreatments.tsx
More file actions
25 lines (22 loc) · 991 Bytes
/
SplitTreatments.tsx
File metadata and controls
25 lines (22 loc) · 991 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import * as React from 'react';
import { SplitContext } from './SplitContext';
import { ISplitTreatmentsProps } from './types';
import { useSplitTreatments } from './useSplitTreatments';
/**
* SplitTreatments accepts a list of feature flag names and optional attributes. It accesses the client at SplitContext to
* call the 'client.getTreatmentsWithConfig()' method if the `names` prop is provided, or the 'client.getTreatmentsWithConfigByFlagSets()' method
* if the `flagSets` prop is provided. It then passes the resulting treatments to a child component as a function.
*
* @deprecated `SplitTreatments` will be removed in a future major release. We recommend replacing it with the `useTreatment*` hooks.
*/
export function SplitTreatments(props: ISplitTreatmentsProps) {
const { children } = props;
const context = useSplitTreatments(props);
return (
<SplitContext.Provider value={context}>
{
children(context)
}
</SplitContext.Provider>
);
}