Is there a suggested approach for focussing input fields when a component is rendered? The autoFocus parameter works on a page refresh, but not when replacing the current contents.
The following approach does not work as the ref is associated with the Input class instance as opposed to the rendered input tag, and the focus() call is not forwarded:
componentDidMount() {
this.inputField.focus();
}
render() {
return (
<div>
<Input ref={ (input) => { this.inputField = input } } name="foo" />
</div>
)
}
I'm quite new to React, so maybe I'm missing something.
Thanks.