React useRef


import { useRef } from 'react';



function App() {

  const inputRef = useRef();



  const handleSubmit = () => {

    console.log('Input value:', inputRef.current.value);

  };



  return (

    <div>

      <input ref={inputRef} type="text" />

      <button onClick={handleSubmit}>Submit</button>

    </div>

  );

}

export default App;

Leave a Comment