SwitchUp SwitchUp Ranked Best Coding Bootcamps 2025

[Reactjs] How do you focus on an input when the page is loaded?

Altcademy Team wrote on 7 February 2018

You should do it in componentDidMount
render: function() { return <TextInput ref={(c) => this._input = c} />; }, componentDidMount: function() { this._input.focus(); },

Trusted by

Students and instructors from world-class organizations

Join the upcoming Cohort #112

Enroll for April 6th, 2026