import React, { useRef } from "react";

export default text => {
  const textareaRef = useRef(null);
  const copyText = () => {
    textareaRef.current.select();
    document.execCommand("copy");
  };
  const hiddenTextArea = (
    <textarea
      ref={textareaRef}
      className="click-to-copy__textarea"
      value={text}
      readOnly
    />)
  ;

  return [hiddenTextArea, copyText]
}
