I'm using ReactJS and when a user clicks a Button I want to copy some div content to clipboard.
I can't see why this code does not result in the data being copied to the clipboard. am giving value from redux store when its true am coping content from div
componentDidUpdate(prevProps, prevState, snapshot) {
console.log("value to copy is-->", this.props.copy);
var copyText = document.getElementById("myInput");
/* Select the text field */
console.log("copyText-->", copyText);
console.log("document-->", document);
/* Copy the text inside the text field */
document.execCommand("copy");
}