How to set focus on an input field after rendering?

@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.

Leave a Comment