v0.1.8
- We included hooks support: π
import { useSplit } form 'react-splitio';
const [feature1, config] = useSplit('feature1');
if (feature1 === 'on') {
return <Feature1 />;
}- Changed
clientto be nullable.
Now we don't have to fake a default client ({} as SplitIO.Client).
This will prevent error if client is not defined and we try to callgetTreatmentsWithConfig. - Changed
lastUpdateto just be0instead ofnullfor default.
Since it is a unix timestamp check 0 functions fine. - Setting
lastUpdateto "now" when the client is ready, because I'm pretty sure that's the time it has the treatments loaded from server. - We're not re-creating the client if the config options have changed.
By giving all the config options as a dependency list touseEffect. - Converted
SplitProviderto a function component.
Attributes on Split components
- Adding the ability to include attributes when using Split components:
<Split name='feature1' attributes={{ paying_customer: true }}>
{(value: TreatmentWithConfig) => {...}
</Split>Advanced: Instantiate multiple/shared SDK clients
- Allow for creating new clients by key. (#5)
- We also support multiple clients instantiation as described in the Split.io documentation.
All you need to do is wrap your Split component with SplitClient passing key and optionally trafficType like so:
<SplitClient key="myKey" trafficType="...">
<Split name="...">
</SplitClient>