score:0

you could use a ref to get the current value of the textarea. i did a small repro on stackblitz and here is the code :

import react from "react";
import "./style.css";

export default function app() {
  const textarearef = react.createref();
  const [val, setval] = react.usestate();

  const copy = _ => {
    setval(textarearef.current.value);
  } 

  return (
    <div>
      <textarea ref={textarearef}></textarea>
      <editortoolbar copy={copy} />
      <hr />
      copied value: {val}
    </div>
  );
}

const editortoolbar = ({copy}) => {
  return <button onclick={copy}>copy</button>
}


Related Query

More Query from same tag