So I'm trying to copy text to clipboard when user clicks on an html element in react. So far I've only seen solutions for html & Javascript, but none of them related to just react. For example, using query selectors. So I'm mapping through an array to provide text: whenever a user clicks on that mapped element, i want to copy to clipboard. Like so:
const array = ['Email', 'Phone', 'Address']
const arrayrow = array.map(el=>{
return <p onClick={()=>copyToClipboard()}>
{el}
</p>
})
So just wondering how i should go about writing this function.
function copyToClipboard(){}