Chrome Extension

onPaste event return blank target value React

I am using onPaste event in react on an input field and want to get its value inside function but e.target.value is returning blank value. Is there any way to get input value onPaste event.

1 Answers

You can use e.clipboardData.getData('Text') which will return you text that is copied on clipboard and you are pasting it inside input. The code function can be written as

handleInputPaste = (e) => {
    const value = e.clipboardData.getData('Text');
    console.log(value);
},
Never leave your website again in search of code snippets by installing our chrome extension.