Why is this search input not clickable? Using react-native-google-places-autocomplete

Viewed 101

Hello everybody!

I am developing a weather application on React Native. In my project I have installed react-native-google-places-autocomplete

I took the code of a basic example from the documentation and inserted it into my application:

import React from 'react';
import { GooglePlacesAutocomplete } from 'react-native-google-places-autocomplete';

export const GooglePlacesInput = () => {
    return (
        <GooglePlacesAutocomplete
            placeholder='Search'
            onPress={(data, details = null) => {
                // 'details' is provided when fetchDetails = true
                console.log(data, details);
            }}
            query={{
                key: 'my key here...',
                language: 'en',
            }}
        />
    );
}

Screenshot here

Hurray, everything works. But for some reason, the search bar is not clickable. I click on it, but nothing happens, I cannot write there.

Please tell me what could be the problem?

1 Answers

Perhaps you need this:

const ref = useRef();

useEffect(() => {
    ref.current?.setAddressText('Some Text');
}, []);

and then in your view:

<GooglePlacesAutocomplete
    ref={ref}
    ...
/>
Related