Watch this example video
https://www.youtube.com/watch?v=LDS1ll93P-s&t=843s
in summary import useRef from react
inside the component
use the useRef to create an inputRef
import {useRef} from "react";
const FormInputComponent = () => {
const inputRef = useRef();
const handleSubmit = e => {
// get the ref value
const inputValue = inputRef.current.value;
// clear the input
inputRef.current.value = "";
// do stuff with the input data
}
return(
<>
//in the form
<form onSubmit={handleSubmit}>
<input type="text" ref={inputRef} />
</form>
</>
);
}