Autofocus form field

can someone please advise how can I get it to autofocus on the name field when the contact form is clicked, I tried adding autofocus prop but it did not work

this commit is not working

I am using the wrong lifecycle? because comp did mount is called when the app initally loads, it is an SPA, yet id like to autofocus on name field when the contact form is clicked. What is the quickest way to achieve this? I have to extract this into a route?

The React docs show an example of how to do focus an input that you should be able to reference to do this (the doc example is not exactly what you need, but shows you how to correctly use a ref to focus an input).

Overview of the steps you would need:

  1. Create a ref in your constructor to store the input field you want to focus
  2. Be sure you include the ref as a prop on the input field
  3. Handle a click on your form, in the click handler execute a function that uses the ref to focus the input field