I\'m sure there is a way to do this, but I just can\'t see how yet.
What I\'d like to do, is add a Picker component, but rather than hard-code the list of items, fet
No Loops required, here how i did in my react native based project, similar to above answer to bind or add data dynamically in Picker
import React, {Component} from 'react';
import {Picker,View} from 'react-native';
export default class SampleApp extends Component {
constructor(props){
super(props);
// HARD CODED DATA , YOU CAN REPLACE THIS DATA WITH API CALL DATA IN ComponentDidMount()
//or in Constructor because countryData is not state.
this.countryData = ["India","Pakistan","USA"];
// STATE
this.state({
selectedCountry : null
});
}
// Our country list generator for picker
countryList = () =>{
return( this.countryData.map( (x,i) => {
return( )} ));
}
// RENDER
render() {
return (
( this.setState({selectedCountry : value}) )}>
{ this.countryList() }
);
}
}
Hope you find my example simple to understand ;)