A Solution to Copy to Clipboard!

copyBoxRef = React.createRef();
<div className=”copyBox” ref={this.copyBoxRef}>
handleClick = ev => {const copyBoxElement =this.copyBoxRef.current;copyBoxElement.contentEditable = true;copyBoxElement.focus();document.execCommand('selectAll');document.execCommand('copy');copyBoxElement.contentEditable = false;getSelection().empty();};
getSelection().empty();

#WomanInTech — Senior Engineer at BCG Digital Ventures — General Assembly London Alumna

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store