how to fill picker (android) of react native with fetch how to fill picker (android) of react native with fetch reactjs reactjs

how to fill picker (android) of react native with fetch


You should set the picker items based on your state by mapping them, for example:

<Picker style={styles.picker}        itemStyle={styles.items}        selectedValue={this.state.client}        onValueChange={(cli) => this.setState({client: cli})}>            {this.state.clients.map((l, i) => {return <Picker.Item value={l} label={"Cliente " + i} key={i}  /> })}    </Picker>

When you receive the data from fetch, you just update the state of "clients", as you are doing, and the picker items will be updated automatically.

An example can be found here where the items are updated based on clicking the button: https://rnplay.org/apps/XfkfnQ