user17880509
user17880509

Reputation: 71

Next.js event type error in arrow function

I've created my handleChange() function with some event to handle event from my input. The problem is that I don't know what to add to solve the error.

Here below screenshot of this:

enter image description here

I'm using Next.js. In React I would never see something like that.

Thank you in advance for help.:)

Upvotes: 0

Views: 1403

Answers (1)

jedrzej.kurylo
jedrzej.kurylo

Reputation: 40919

It looks like you've set up your Next.js project with TypeScript and your typescript configuration has noImplicitAny check enabled, that causes that error to be reported.

Easiest way to fix it would be to explicitly set event type to any.

const handleChange = (event: any) => {

Much better way to fix it would be to use a proper TypeScript type React.ChangeEvent

const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {

Upvotes: 2

Related Questions