ref (refence)

ref (refence)

3초 후에 input 태그에 focus가 되게 ref 속성을 주었다.

import React, { useRef } from "react"; const App = () => { const test = useRef(); // test에는 ref를 설정해준 input 태그가 담깁니다. setTimeout(() => test.current.focus(), 3000); return ( <> Hello ); }; export default App;

from http://darrengwon.tistory.com/178 by ccl(A) rewrite - 2020-03-22 19:20:16

댓글

이 블로그의 인기 게시물

[React] - 18) 프로젝트 빌드하기(+코드 스플리팅)

리액트에서 이미지를 다루는 방법

React에서 웹팩 설치하기