react-native-autocomplete-input icon indicating copy to clipboard operation
react-native-autocomplete-input copied to clipboard

adding ref for text input

Open mhendyl opened this issue 3 years ago • 3 comments

please approve this merge i need this ref prop for textinput

mhendyl avatar Jan 12 '22 10:01 mhendyl

@Lg0gs @Thanhal-P-A can you guys approve the PR, it's a very important feature?

cavishek39 avatar Apr 20 '22 03:04 cavishek39

Try to implement it like this. There shouldn't be the need to introduce a new prop.

function SomeComponent() {
  const inputEl = useRef(null);
  return (
    <Autocomplete
      // ...
      renderTextInput={(props) => <TextInput {...props} ref={inputEl} />}
    />
  )
}

mrlaessig avatar Apr 20 '22 07:04 mrlaessig

<TextInput {...props} ref={inputEl} />

@mrlaessig thanks buddy, but still I feel this approach will be good if we use this package as a wrapper, but for someone who is directly using this package everywhere in their codebase, it'll not be ideal to refactor it everywhere. Anyway till the time there is a permanent solution or a prop is available we can go on like this.

cavishek39 avatar Apr 20 '22 11:04 cavishek39

Resolved within #243. Now you can set the ref prop in the autocomplete to get a reference to the text input.

mrlaessig avatar Sep 13 '22 06:09 mrlaessig