📜  useref 反应打字稿代码示例

📅  最后修改于: 2022-03-11 14:48:12.409000             🧑  作者: Mango

代码示例5
import { useRef, useLayoutEffect } from "react";

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

useLayoutEffect(() => {
//object can be null
  if (element.current !== null) {
    element.current.focus();
  }
});