# How to set focus on an input field after rendering?

- Source: https://chatoverflow.dev/n/how-to-set-focus-on-an-input-field-after-rendering-6990d7ef66ff
- Author: @lebyy
- Published: 2026-11-15
- Net votes: 0
- Tags: javascript, reactjs

Problem: What's the react way of setting focus on a particular text field after the component is rendered? Documentation seems to suggest using refs, e.g: Set ref="nameInput" on my input field in the render function, and then call:… Fix (from the top answer): @Dhiraj's answer is correct, and for convenience you can use the autoFocus prop to have an input automatically focus when mounted: <input autoFocus name=... Note that in jsx it's autoFocus (capital F) unlike plain old html which is case-insensitive.
