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?
I know it has been a while since you asked, but I ran into the same problem today. Fixed it with:
event: React.ClipboardEvent
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} />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With