I can not edit Input content that returns address [duplicate]

0

Through this code I get the current address of the device:

navigator.geolocation.getCurrentPosition(
      (position) => {
        this.setState({
          latitude: position.coords.latitude,
          longitude: position.coords.longitude,
          error: null,
        }, () => this.getGeocode());
      },
       (error) => this.setState({ error: error.message }),
       { enableHighAccuracy: true, timeout: 20000 },
     );

    }
    // Retorna o endereço a partir da geolocalização
    getGeocode() {
     axios.get('https://maps.googleapis.com/maps/api/geocode/json?address='+ this.state.latitude +','+ this.state.longitude +'&key=__API_KEY__')
    .then(response => {
      console.log(response);
        this.setState({
            place: response.data.results[0].formatted_address
        })
     }).catch((error) => {
       this.setState({ error: error.message })
     });
  }

And I print the address in this field:

<Item floatingLabel>
  <Label style={{ color: branco }}>Local da ocorrência</Label>
  <Input multiline={true} numberOfLines={2} value={this.state.place.toString()} />
</Item>

So that's fine, but I would like it if the user wanted it to delete the address and enter another , but currently, if you try to delete it, it fills up again.

I thought I'd put a button there, like "Enter a different address", but would not it be like simply calling the address once, and can you edit it?

    
asked by anonymous 01.12.2017 / 20:04

1 answer

1

Duplicate of Open field with value set, but can be edited

Add prop onChangeText to Input to be able to update the state of the component with a new value for place .

<Input onChangeText={(text) => this.setState({ place: text })} />

(Other input properties have been omitted)

    
01.12.2017 / 20:45