useRef

김혁중·2022년 3월 23일
0

useRef

export default function App() {
  const inputEl = useRef(null)
  
  const onButtonClick = () => {
    inputEl.current.focus()
  }

  return (
    <div>
      <Input ref={inputEl} inputColor="green" defaultValue="네이버" type="text" />
      <Button onClick={onButtonClick}>Naver</Button>
    </div>
  );
}

inputRef.current.value

profile
Digital Artist가 되고 싶은 초보 개발자

0개의 댓글