Verwenden von React Useref Hook, um Eingabefeld auf der Schaltfläche zu fokussieren. Klicken Sie auf Schaltfläche Klicken
function TextInputWithFocusButton() {
const inputEl = useRef(null);
const onButtonClick = () => {
// `current` points to the mounted text input element
inputEl.current.focus();
};
return (
<>
<input ref={inputEl} type="text" />
<button onClick={onButtonClick}>Focus the input</button>
</>
);
}
Salo Hopeless