0
Don't want to call a certain function on specific conditions
I am using react js, I am calling a function (handleRowClick) onClick on table row but there is a "copy to clipboard" button as well in the row. I don't want (handleRowClick) to be called when "copy to clipboard" button is clicked. Any ideas on how can i achieve that?
3 Réponses
0
You can call the stopPropagation() method on the event in the function that handles the "copy to clipboard".
For example:
const handleCopyToClipboard = (e)=>{
e.stopPropagation();
//function body
}
0
Baribor Saturday There is no explicit function for copy to clipboard. I am using a utility component for that <CopyToClipboard text={...} />
0
Ashutosh Raturi okay. Try wrapping the CopyToClipboard component in a div, then add a click listener to the div that will stop the propagation