-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert HOCs and Render Props components
- Loading branch information
1 parent
cdd1396
commit a715ff4
Showing
20 changed files
with
1,597 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import React from 'react'; | ||
import { SplitContext } from './SplitContext'; | ||
import { ISplitClientProps } from './types'; | ||
import { useSplitClient } from './useSplitClient'; | ||
|
||
/** | ||
* SplitClient will initialize a new SDK client and listen for its events in order to update the Split Context. | ||
* Children components will have access to the new client when accessing Split Context. | ||
* | ||
* The underlying SDK client can be changed during the component lifecycle | ||
* if the component is updated with a different splitKey prop. | ||
* | ||
* @deprecated `SplitClient` will be removed in a future major release. We recommend replacing it with the `useSplitClient` hook. | ||
*/ | ||
export function SplitClient(props: ISplitClientProps) { | ||
const { children } = props; | ||
const context = useSplitClient(props); | ||
|
||
return ( | ||
<SplitContext.Provider value={context}> | ||
{ | ||
typeof children === 'function' ? | ||
children(context) : | ||
children | ||
} | ||
</SplitContext.Provider> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import 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 `useSplitTreatments` hook. | ||
*/ | ||
export function SplitTreatments(props: ISplitTreatmentsProps) { | ||
const { children } = props; | ||
const context = useSplitTreatments(props); | ||
|
||
return ( | ||
<SplitContext.Provider value={context}> | ||
{ | ||
children(context) | ||
} | ||
</SplitContext.Provider> | ||
); | ||
} |
Oops, something went wrong.