close

[Solved] Typescript: React event types

Hello Guys, How are you all? Hope You all Are Fine. Today I get the following error Typescript: React event types in javascript. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How Typescript: React event types Error Occurs?

Today I get the following error Typescript: React event types in javascript.

How To Solve Typescript: React event types Error ?

  1. How To Solve Typescript: React event types Error ?

    To Solve Typescript: React event types Error for update: event: React.ChangeEvent for submit: event: React.FormEvent for click: event: React.MouseEvent

  2. Typescript: React event types

    To Solve Typescript: React event types Error for update: event: React.ChangeEvent for submit: event: React.FormEvent for click: event: React.MouseEvent

Solution 1

To combine both Nitzan’s and Edwin’s answers, I found that something like this works for me:

update = (e: React.FormEvent<EventTarget>): void => {
    let target = e.target as HTMLInputElement;
    this.props.login[target.name] = target.value;
}

Solution 2

for update: event: React.ChangeEvent for submit: event: React.FormEvent for click: event: React.MouseEvent

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also Read

Leave a Comment