Skip to content

Hooks Support and Improvements

Pre-release
Pre-release
Compare
Choose a tag to compare
@samuelcastro samuelcastro released this 22 Aug 21:44
· 48 commits to master since this release
f48c23e
  • 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.