Answers for "createref in functional component"

0

createref in functional component

function CustomTextInput(props) {
  // textInput must be declared here so the ref can refer to it
  const textInput = useRef(null);
  
  function handleClick() {
    textInput.current.focus();
  }
  
  return (
    <div>
      <input
        type="text"
        ref={textInput} />
    </div>
  );
}
Posted by: Guest on July-26-2020

Code answers related to "createref in functional component"

Code answers related to "Javascript"

Browse Popular Code Answers by Language