Answers for "useref typescript type inside form"

3

useref input typescript

const input = React.useRef<HTMLInputElement>(null);
Posted by: Guest on January-12-2021
0

useref typescript

import { useRef, useLayoutEffect } from "react";

//HTMLInputElement || define the type of element
const element = useRef<HTMLInputElement>(null);

useLayoutEffect(() => {
//object can be null
  if (element.current !== null) {
    element.current.focus();
  }
});
Posted by: Guest on November-21-2021

Code answers related to "TypeScript"

Browse Popular Code Answers by Language