---
title: "Discussion on \"React hook - useRef - auto focus input\" | Hashnode"
description: "Discussion on \"React hook - useRef - auto focus input\". useRef giúp chúng ta thao tác và xử lý DOM\n1. Import các thứ cần thiết\nimport { useEffect, useRef } from 'react'\n2. Tạo ref\nconst inputRef = useRef()\n3. Gắn ref vào input\n<input type=\"text\" ref={inputRef} />\n4. Tự động focus khi page loaded\nuseEffect..."
url: "https://hashnode.com/posts/react-hook-useref-auto-focus-input/60f8f67f3e181324dac7428d"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [React hook - useRef - auto focus input](https://kentrung.hashnode.dev/react-hook-useref-auto-focus-input?utm_source=hashnode&utm_medium=feed)

useRef giúp chúng ta thao tác và xử lý DOM 1. Import các thứ cần thiết import { useEffect, useRef } from 'react' 2. Tạo ref const inputRef = useRef() 3. Gắn ref vào input <input type="text" ref={inputRef} /> 4. Tự động focus khi page loaded useEffect...

Jul 22, 2021 · 1 min read · kentrung.hashnode.dev  
Read the article

-   [#reactjs](https://hashnode.com/tag/reactjs)
-   [#reacthooks](https://hashnode.com/tag/reacthooks)

## Written by

[ken trung](https://hashnode.com/@kentrung)

@kentrung · Vietnam

  
[View profile](https://hashnode.com/@kentrung)

developer

## Responses

Markdown supported · ⌘↵ to post

No responses yet.
