Hi! We use the `@growthbook/growthbook-react` -pac...
# ask-questions
p
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
@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
0.11.1
f
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
gotcha, thanks 👍
sorry, follow up on the last question: any idea why TS isn't complaining about this wrong key?
f
The react hooks need a little extra setup to work with the types. https://docs.growthbook.io/lib/react#usefeatureisont
🙌 1