How can I set the focus on a material-ui TextField
component?
componentDidMount() { ReactDom.findDomNode(this.refs.myControl).focus() }
I have tried above code, but it does not work :(
To give focus to a text field as soon as it's visible, use the autofocus property. TextField( autofocus: true, );
You can use the autoFocus
attribute.
<TextField value="some value" autoFocus />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With