Open field with value set, but can be edited

0

I'm using floatingLabel of NativeBase :

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

This gets the address from the API and is already filled, but if the user tries to edit it can not.

I tried to use defaulValue , as described in documentation of TextInput :

  

Provides an initial value that will change when the user starts   typing. Useful for simple use-cases where you do not want to deal with   listening to events and updating the value to keep the controlled   state in sync.

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

But this did not work, it just does not appreciate any value when loading.

Any ideas how I can do this?

    
asked by anonymous 26.10.2017 / 21:38

1 answer

1

When the render method is called, the input value comes from the this.state.place state. The input will only change text if the state is changed. Then you have to use% prop to change the state and make render () be called again with the new value of onChangeText={(text) => this.setState({ place: text })} .

According to the documentation NativeBase Input comes from the TextInput of React Native, so it should be able to receive the prop onChangeText.

Ref link

  

Input is a NativeBase component built on top of React Native's TextInput

    
01.12.2017 / 20:42