i-like-robots/react-tags

How to implement Autofocus

taylorhlabs opened this issue · 1 comments

This is not really a feature request, but a documentation/readme related request. Since the autofocus option has been removed, is there a recommended way to implement autofocus? I have tried a few different ways but can't get it to work. Thanks for any input or suggested implementations!

For now, I got it to work using a useEffect() hook. Not sure if this is the best way? I should also note I am using react-tags as function component not class component.

useEffect(() => {
  let input = document.getElementsByClassName('react-tags__search-input')[0];
  if (input) input.focus();
});