You are given a React component InputFocusOnClick that renders two input fields and a button. Your task is to implement the functionality where clicking the button focuses the user input on the first input field.
useRef hook.handleFocus function.handleFocus function to the button's onClick event.const InputFocusOnClick = () => { // TODO: return ( <div> <label htmlFor="input1">First Input:</label> <input id="input1" type="text" data-testid="input1" /> <br /> <label htmlFor="input2">Second Input:</label> <input id="input2" type="text" data-testid="input2" /> <br /> <button data-testid="focus-button"> Focus First Input </button> </div> ); }; export default InputFocusOnClick;
Tests