You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is there a suggested approach for focussing input fields when a component is rendered? The autoFocus parameter works on a page refresh, but not when replacing the current contents.
The following approach does not work as the ref is associated with the Input class instance as opposed to the rendered input tag, and the focus() call is not forwarded:
My understanding is that the use of this method is not recommended. It also doesn't appear to work in preact. Perhaps for these cases it will be easier just to provide the input box manually.
It looks like findDomNode is supported in the preact-compat module, but I'd honestly prefer to keep the code as lean as possible.
Given that focus() is an important function for Input boxes, perhaps it's worth adding a wrapper method to the Input component? That way the regular and recommended ref can be used without issue.
Is there a suggested approach for focussing input fields when a component is rendered? The
autoFocus
parameter works on a page refresh, but not when replacing the current contents.The following approach does not work as the ref is associated with the
Input
class instance as opposed to the renderedinput
tag, and thefocus()
call is not forwarded:I'm quite new to React, so maybe I'm missing something.
Thanks.
The text was updated successfully, but these errors were encountered: