10

I'm building a component and currently I'm watching for events on input and textarea with a typed event via InputEvent: React.KeyboardEvent<HTMLInputElement> | React.KeyboardEvent<HTMLTextAreaElement>

I'm having trouble determining which event type would be fired when pasting input into these elements. Would I be reduced to using any for this or do they have an event that would be relevant when pasting input?

2 Answers 2

18

I know it has been a while since you asked, but I ran into the same problem today. Fixed it with:

event: React.ClipboardEvent
Sign up to request clarification or add additional context in comments.

Comments

4

Another way to handle the paste event: You can use onPaste event in input.

paste(e){
    // e.target.value: this is prev value before paste.
  }
...
<input type="text" onPaste={this.paste} />

1 Comment

Thank you, the question was more centered around what the event should be "typed" as. This may help someone though!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.