Answers for "react useref section typescript"

9

useref react typescript

const inputRef = React.useRef<HTMLInputElement | null>(null);
Posted by: Guest on April-01-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