FaridSafi / react-native-google-places-autocomplete

Customizable Google Places autocomplete component for iOS and Android React-Native apps
MIT License
2.01k stars 854 forks source link

problem with the ref of focus input #779

Open jblancoh opened 3 years ago

jblancoh commented 3 years ago

Describe the bug

I have a problem with the ref of focus input. I migrated from 1.3.9 to 2.4.1

Reproduction - (required - issue will be closed without this)

Implement the component. Implement useRef then when executing placesRef?.Current?.Focus () in the onWillFocus event of react navigation the app crashed.

Please provide a FULLY REPRODUCIBLE example.

Click to expand! ```javascript { if (placesRef?.current != null) { placesRef?.current?.focus() } }} /> row.description} renderRightButton={RightButton} renderRow={Row} minLenght={3} returnKeyType='search' enablePoweredByContainer={false} fetchDetails query={QUERY_CONFIG} styles={CUSTOM_STYLES} nearbyPlacesAPI='None' debounce={10} predefinedPlaces={PREDEFINED_PLACES} enableHighAccuracyLocation={false} /> ```

Additional context

Add any other context about the problem here, screenshots etc

Simulator Screen Shot - iPhone 8 - 2021-11-08 at 11 45 44

esmailbenmoussa commented 3 years ago

yeap having the same issue, any workaround so far @jblancoh ?

ramisalem commented 3 years ago

Hi, it works for me when I did it in the useEffect hook

React.useEffect(() => {
    ref.current && ref.current?.focus();
  }, []);