Skip to content

v0.1.8

Choose a tag to compare

@samuelcastro samuelcastro released this 17 Sep 18:52
· 31 commits to master since this release
  • We included hooks support: πŸŽ‰
import { useSplit } form 'react-splitio';

const [feature1, config] = useSplit('feature1');

if (feature1 === 'on') {
  return <Feature1 />;
}
  • Changed client to 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 call getTreatmentsWithConfig.
  • Changed lastUpdate to just be 0 instead of null for default.
    Since it is a unix timestamp check 0 functions fine.
  • Setting lastUpdate to "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 to useEffect.
  • Converted SplitProvider to 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>