posthog-js-lite
posthog-js-lite copied to clipboard
feat(flags): FeatureFlag React component
I think we can make feature flags easy to use in a declarative fashion with a Feature component.
Is your feature request related to a problem?
It's related to an opportunity to make feature flags easier to use.
Describe the solution you'd like
Here's some example usages:
<Feature featureKey="simple-flag">
<Section title="Feature Flag">
The feature flag "simple-flag" is enabled!
</Section>
</Feature>
<Feature featureKey="simple-flag" variant="variant-1">
<Section title="Feature Flag">
The feature flag "simple-flag" is enabled with variant "variant-1"!
</Section>
</Feature>
<Feature featureKey="simple-flag" variant="variant-2">
<Section title="Feature Flag">
The feature flag "simple-flag" is enabled with variant "variant-2"!
</Section>
</Feature>
<Feature featureKey="simple-flag" negate={true}>
<Section title="Feature Flag">
The feature flag "simple-flag" is not enabled!
</Section>
</Feature>
Describe alternatives you've considered
Alternative is to not do this.
Related sub-libraries
- [ ] All of them
- [ ] posthog-web
- [ ] posthog-node
- [ ] posthog-ai
- [x] posthog-react-native
Additional context
Some flags require additional information such as person properties and group properties be passed along. I think a first iteration of this would just ignore that. Or we could add a personProperties property that takes a hash if that's easy to do for React.