Check out example codes for "copy text from header tag in javacript". It will help you in understanding the concepts better.

Code Example 1

function copyText() {
  var text = document.getElementById("myText").innerText;
  var elem = document.createElement("textarea");
  document.body.appendChild(elem);
  elem.value = text;
  elem.select();
  document.execCommand("copy");
  document.body.removeChild(elem);
}

Learn ReactJs, React Native from akashmittal.com