#RomanDEV

1 messages · Page 1 of 1 (latest)

pallid sphinxBOT
azure burrow
#

hi! let me think about this

high coral
#

The underlying issue is that you're trying to assign a value to your stripePromise prop using your useState hook that doesn't match it's type defs. You need to make it typed:

useState<>(null)

Trying to think what type you need to use 🤔

#

Maybe it's just useState<Stripe | null>(null)

And: import type { Stripe } from '@stripe/stripe-js'

high coral
#

Ok, this worked for me (just tested):

const [stripePromise, setStripePromise] = React.useState<Promise<Stripe | null>>(null)

React.useEffect(() => {
  setStripePromise(loadStripe(process.env.NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY))
}, [])
sly dirge
#

Thanks for your response. In the tutorial we get the publishable Key from the backend. I have tried, what you have tested and null is underlined and not assignable, but the publishable Key is logged. So perhaps it works. I try it. 🙂

high coral
#

Eh, I don't get any type warnings with your exact code