prehistoric-oxygen-56976
04/14/2023, 1:59 PM@growthbook/growthbook-react
-package to setup growthbook for our React app. With the introduction of the typesafe sdk we were looking at adding the typing to catch the typos etc.
Creating the types (AppFeatures
) with the instructions works well, but when I try to use them when creating the Growthbook-object with the type defined, typescript is complaining with the error Expected 0 type arguments, but got 1.
Our code looks like this
import { GrowthBook } from '@growthbook/growthbook-react';
export const growthbook = new GrowthBook<AppFeatures>({
apiHost: '<https://cdn.growthbook.io>',
clientKey: ...,
decryptionKey: ...,
enableDevMode: ...,
onFeatureUsage: (featureKey, result) => {
...
},
trackingCallback: (experiment, result) => {
...
},
});
The exported growthbook object is used as growthbook.loadFeatures()
when the app renders the first time.
Q: do I need to change to use the @growthbook/growthbook
-package instead or create a custom hook by using the useGrowthbook
-hook as base?future-teacher-7046
@growthbook/growthbook
is a dependency of the react SDK. It's possible it installed an older version of that which doesn't support types yet.prehistoric-oxygen-56976
04/14/2023, 2:26 PM0.11.1
future-teacher-7046
prehistoric-oxygen-56976
04/14/2023, 2:28 PMfuture-teacher-7046