Hooks Support and Improvements
Pre-release
Pre-release
samuelcastro
released this
22 Aug 21:44
·
48 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 callgetTreatmentsWithConfig
. - Changed
lastUpdate
to just be0
instead ofnull
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 touseEffect
. - Converted
SplitProvider
to a function component.