Nativebase: Dynamic Item List of Picker are throwing exception on iOS (working with warnings on Android)

Created on 5 Dec 2016  路  3Comments  路  Source: GeekyAnts/NativeBase

Hi

This is my code to render items dynamically. The state "states" is a non empty array of states with properties.
But it's throwing an exception.

screen shot 2016-12-05 at 5 27 45 pm
![screen shot 2016-12-05 at 1 11 21 pm]
(https://cloud.githubusercontent.com/assets/17562095/20884234/fff0aa34-bb0f-11e6-9eca-52c75b7fdc6d.png)

bug duplicate

All 3 comments

I think this is a duplicate of #314

Hi @sankhadeeproy007 is this resolved?

native-base picker is not working less than 2 items at my side so,

constructor(props) {
  super(props);
  this.state = {
    categories: null,
    categoryActive: '1',
  }
}
//getting categories list from http request or asyncstorage
updateDropdown(){
      const self = this;
      const all_items = self.state.categories.map((category, i) => {
        return (
            <PickerItem key={i} label={category.cat_name} value={category.cat_id} />
          )
       });
       return all_items;
}
render(){
    return (
            <Container>
               <Content>
              { this.state.categories != null && this.state.categories.length>1 ?
              <Picker
                  iosHeader="Select one"
                  mode="dropdown"
                  selectedValue={this.state.categoryActive}
                  onValueChange={this.onValueChange.bind(this)}>
                    {this.updateDropdown()}
             </Picker> : <View />
             }
             </Content>
             </Container>
            );
}
Was this page helpful?
0 / 5 - 0 ratings