We are using RN: 0.40.0.
Is there any way by which we rerender default value after first time render
We are trying to update default value in GooglePlacesAutocomplete "getDefaultValue" attribute by changing state value.
Can anyone suggest any solution?
Same problem here
Ok i wrapped a condition around so that it renders only when the default value is ready. Not an elegant way and probably does not cover you need, but works for me for now.
{this.props.defaultValueReady ? (
<GooglePlacesAutocomplete
query={{
...
/>
) : <View></View>}
@MSSPL-PiyaleeMaiti but i think all in all you are right there is no way of setting the autocomplete input field later on from outside/state you can just set it by typing text as i understood
Are you still working on this? I have the same issue
You can use setAddressText("...").
On your autocomplete component get a reference to the object:
<GooglePlacesAutocomplete ref={(instance) => { this.locationRef = instance }} .../>
and then:
this.locationRef.setAddressText("New York, NY")
Thanks that worked!
@noambonnie Thanks it worked
@noambonnie I can麓t get it to work, when I try this:
getDefaultValue={() => {
this.GooglePlacesRef.setAddressText("Something")
}}
I get an error Cannot read property 'setAddressText' of undefined
@noambonnie Thanks a TON !! Saved my day :)
You can use setAddressText("...").
On your autocomplete component get a reference to the object:
<GooglePlacesAutocomplete ref={(instance) => { this.locationRef = instance }} .../>and then:
this.locationRef.setAddressText("New York, NY")
Where to do this after setting reference?
this.locationRef.setAddressText("New York, NY")
@NeenaMishra12 see this example.
Most helpful comment
You can use setAddressText("...").
On your autocomplete component get a reference to the object:
<GooglePlacesAutocomplete ref={(instance) => { this.locationRef = instance }} .../>and then:
this.locationRef.setAddressText("New York, NY")