Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get pasted value from Reactjs onPaste event

if i have an Reactjs input text element with onPaste event assigned to it, how could I get the pasted value in the response?

at the moment what i get in the console is a SyntheticClipboardEvent with all properties as null. I read that the console.log is a async checker so thats why the majority of values are null as they are looking ahead.

However I am wondering how to get the value.

Cheers

like image 353
Aiden Rigby Avatar asked Sep 28 '15 00:09

Aiden Rigby


People also ask

How do you trigger an event in react?

To add the click event in React using plain JavaScript, you need to use addEventListener() to assign the click event to an element. Create one <button> element as ref props so that it can be accessed to trigger the click event.


1 Answers

onPaste: function(e) {     console.log(e.clipboardData.getData('Text')); }, 
like image 160
Lukas Lukac Avatar answered Sep 21 '22 05:09

Lukas Lukac