-
Notifications
You must be signed in to change notification settings - Fork 175
feat: react library #540
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: react library #540
Conversation
@benjackwhite would be great to get your input on the bundling when you have a chance. Feel free to ignore the files outside of the '/react' folder - I'll clean these up tomorrow |
@ivanagas here's the plan for the new react API: |
The react native API has the hooks However, with the payload function too I wonder if
@neilkakkar @EDsCODE and @liyiy what API do you want for the react feature flags? |
I think it links to the issues that Ben and I were mentioning For the |
Hmm, removing it means we end up missing a big piece of usefulness here, since right now there is no equivalent of I'll leave it up to you though! If it helps, you can leave out |
Good point. I like the idea of a |
Yeah, The boolean is the variant key for a flag that has no variants (and responds with true), which exists for backwards compatibility iirc, but yeah for a flag with no variants you really shouldn't be calling |
I've just tried it and for a boolean value getFeatureFlag returns I'd be keen to merge what we have so far and then in parallel I think you're still working through the proposal ben mentioned to streamline it to just getFeatureFlagPayload and getFeatureFlagVariantKey (unless you have reached a decision) |
@neilkakkar if you agree, would you mind giving a final review of the PR including a check of the new removing event listener function I added |
Didn't manually try it out, but I'm hoping you have! Code looks good |
Size Change: +896 B (0%) Total Size: 2.28 MB
ℹ️ View Unchanged
|
@neilkakkar based on our discussion I agree and it makes sense to add useFeatureFlagVariantKey - I've added that here: 7376f32 can you confirm you're happy with it? |
@joethreepwood could be good to have some marketing support around this once we've updated the docs. Main benefit for users it that it makes implementation much easier/quicker. |
Think it can go in the Changelog this week, or is this going to drift to next? |
I'll update the docs to a good enough place by EOD that it can go in this week |
@joethreepwood as discussed @pauldambra has a few more tweaks he wants to do so likely this will be next week instead |
I thought that was in reference to Dashboard templates, or is that the case here too? |
I had the wrong tab open - my fault! Yep this is ready to go when the docs merge later today. Dashboard templates will need another week |
I know its been a while since this was implemented - but I wanted to drop a note that I was recently tripped up by the decision to not set the initial state of the flag: https://github.com/PostHog/posthog-js/blob/main/react/src/hooks/useFeatureFlagEnabled.ts#L7-L9 This results in users getting undefined and then getting the flag value - even when the flag value is known at startup. I stumbled upon this because of some undesired thrashing and rendering in our app. IMO the workarounds should be on nextjs users or SSR users to maybe have a separate set of functions - and for everyone that does not care about SSR to not be hit with this behavior. |
Adds a react library which can be used by create react apps and next js
API heavily inspired by posthog's react native app
Introduces the provider:
<PostHogProvider>...</PostHogProvider>
which can either take an initiated posthog client, or an API key and optionsAnd the following hooks:
TODO:
After merging:
Checklist