How to set focus to a materialUI TextField?
You can use the autoFocus
attribute.
<TextField value="some value" autoFocus />
For React 16.8.6, you should use the inputRef
property of TextField to set focus. I tried ref
property but it doesn't work.
<TextField
inputRef={input => input && input.focus()}
/>
Material-ui doc says:
inputRef
: Use this property to pass a ref callback to the native input component.