PostHog / posthog-js

Send usage data from your web app or site to PostHog, with autocapture.
https://posthog.com/docs/libraries/js
Other
235 stars 103 forks source link

PostHogFeature provider incorrect type #777

Open SamKomesarook opened 10 months ago

SamKomesarook commented 10 months ago

When using the sample PostHogFeature provider code in a NextJS project with TS, the following err appears:

Type '(payload: any) => Element' is not assignable to type 'string'.

<PostHogFeature flag="sample" match={true}>
                  {(payload) => {
                    return (
                      <div>
                        <h1>{payload.welcomeMessage}</h1>
                        <p>Thanks for trying out our feature flags.</p>
                      </div>
                    )
                  }}
                </PostHogFeature>

Is there an issue with the provider code?

benjackwhite commented 10 months ago

Can't say for sure. Quick glance at the code shows this as the type correctly but it could be something else going on?

SamKomesarook commented 10 months ago

While it is possible to get the payloads from the posthog react hooks, it would be great if the provider code could be fixed.