I am trying to build a custom paste event in React. I have a problem though that if I use the React events the event.preventDefault()
is run after the default action already occurred.
Here is the code:
render() {
return (
<div
className='compositionText'
onPasteCapture={this.handlePaste}>
</div>
);
}
I have succeeded in doing the same with DOM event listeners:
componentDidMount() {
this.getDOMNode().addEventListener('paste', this.handlePaste, true);
},
Can anyone tell me why the first solution doesn't work and how I can achieve this in the React way?
UPDATE: I want to add that I am using the Trix editor within that div, if that changes anything.