Como usar o React refs para focar um campo Redux Form?
Estou tentando usar o React refs para focar um campo Redux-Form quando ele é montado.
Quando eu tentothis.refs.title.getRenderedComponent().focus()
nocomponentDidMount
, é gerado um erro dizendo:
edit_fund.js:77 Uncaught TypeError: Cannot read property 'getRenderedComponent' of undefined
Quando eu console.log this.refs, ele é principalmente um objeto vazio e às vezes identifica 'title' como sendo um ref, mas não é confiável.
Estou usando referências incorretamente? Meu código está abaixo para referência.
componentDidMount = () => {
this.refs.title
.getRenderedComponent()
.focus();
}
...
<Field
id="title"
name="title"
component={FormInput}
type="text"
ref="title" withRef
/>