How to set focus to a Material UI TextField?

For React 16.8.6, you should use the inputRef property of TextField to set focus.

<TextField
  inputRef={input => input && input.focus()}
/>

Material UI doc says:

inputRef: Use this property to pass a ref callback to the native input component.

The ref prop wouldn’t work. It gives a reference to the root DOM element of the TextField which is the parent of the <input> element.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)