I’m new to Typescript and I wactch a tutorial that use next-auth, but since I following the tutorial with Typescript, I encounter this error when using getProviders function.
As you can see when I try to update the state it show an error. What is the cause and how can I solve this? Thank you
The state you defined infers that it’ll be only null. You need to add type to that state such as useState<T>. Instead of T, you can copy and paste the typeof response
2
Answers
The state you defined infers that it’ll be only null. You need to add type to that state such as
useState<T>
. Instead of T, you can copy and paste the typeof responsethis is your
useState
if you hover over
providers
, its type is referred asBut then you are setting providers with
getProviders
. this is type forgetProviders
you should set the state like this: