https://www.growthbook.io/ logo
p

prehistoric-oxygen-56976

04/14/2023, 1:59 PM
Hi! We use the
@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
Copy code
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?
f

future-teacher-7046

04/14/2023, 2:24 PM
@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.
What version of the react SDK are you using?
p

prehistoric-oxygen-56976

04/14/2023, 2:26 PM
0.11.1
f

future-teacher-7046

04/14/2023, 2:27 PM
Ok, the latest version is 0.15.0 so that's why you aren't seeing typed support. If you update to the latest it should work.
p

prehistoric-oxygen-56976

04/14/2023, 2:28 PM
gotcha, thanks 👍
sorry, follow up on the last question: any idea why TS isn't complaining about this wrong key?
f

future-teacher-7046

04/14/2023, 2:50 PM
The react hooks need a little extra setup to work with the types. https://docs.growthbook.io/lib/react#usefeatureisont
🙌 1
2 Views