Unform: Input Focus

Created on 4 Oct 2019  路  3Comments  路  Source: unform/unform

I'm not getting input focus
I'm trying to implement this hook that is in the official React documentation.

function TextInputWithFocusButton() {
  const inputEl = useRef(null);
  const onButtonClick = () => {
    // `current` points to the mounted text input element
    inputEl.current.focus();
  };
  return (
    <>
      <input ref={inputEl} type="text" />
      <button onClick={onButtonClick}>Focus the input</button>
    </>
  );
}
bug

Most helpful comment

Please format your code using

image

I'm not able to edit your issue, sorry.

Updated.
It's the React Documentation code ... I put the ref on Input inside the Form component

All 3 comments

Please format your code using

image

I'm not able to edit your issue, sorry.

Please format your code using

image

I'm not able to edit your issue, sorry.

Updated.
It's the React Documentation code ... I put the ref on Input inside the Form component

Hello @SereiaMaster, you good?

We've released Unform 2.0 馃帀

Now you can access the input reference by using the getFieldRef function.

Check this guide to upgrade to v2: https://unform.dev/migration-guide

And this guide to understand how to focus the inputs: https://unform.dev/recipes/accessing-field-ref

I'll close the issue for now but feel free to reopen or create new ones if you have any problems.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

davifalta picture davifalta  路  4Comments

fmontone picture fmontone  路  4Comments

korczas picture korczas  路  5Comments

Davidiasdesousa picture Davidiasdesousa  路  3Comments

medeiroshudson picture medeiroshudson  路  3Comments