react js hooks useRef to show input variable value without using name property, and use for set focus
code
import { useRef } from "react";
function App() {
const num1 = useRef();
const focusInput = () => {
num1.current.focus();
alert(num1.current.value)
};
return (
<>
<input type="text" ref={num1} />
<button onClick={focusInput}>Focus Input</button>
</>
);
}
export default App