Next.js Discord

Discord Forum

Why I can't use experimental_useFormState

Answered
Cairn Terrier posted this in #help-forum
Open in Discord
Avatar
Cairn TerrierOP
hii everyone, I recently watch the nextJS tutorial video for formHandler using useFormState, but when i try it on my code, it doesn't work, am i do it wrong? need some help, thanks
Image
Answered by Risky
like do something like this
Image
View full answer

14 Replies

Avatar
Risky
thats because it isn't in the typescript types
it should work otherwise
Avatar
Cairn TerrierOP
so, what should i do?
sorry i am still newbie in typescript btw 😭
Avatar
Risky
umm you could try adding // @ts-expect-error on top of the error line and not have the types for some time
Avatar
Cairn TerrierOP
so, i just need to initialize the type of the useFormState isn't it?
it doesn't work
Avatar
Risky
like show the code you did as i thought you can make it quiet from doing that
Avatar
Cairn TerrierOP
like this?
Image
Avatar
Risky
like do something like this
Image
Answer
Avatar
Risky
the expect error will warn you when it has types next
@Cairn Terrier did it work? and can you try using experimental_useFormState and see if that works as intended?
Avatar
Cairn TerrierOP
the error was gone, but i have another problem, so i decided for change to old code, without using the experimental feature