Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Values not displaying #64

Open
amanpates opened this issue Jul 25, 2019 · 1 comment
Open

Values not displaying #64

amanpates opened this issue Jul 25, 2019 · 1 comment

Comments

@amanpates
Copy link

I'm having an issue where my picker shows up, but the assigned values are not being displayed. Here is my code:

State:

this.state = {
      selectedItem: 0,
      showPicker: false,
      itemList: null,
}

I set the value for itemList later on based on a database call.

this.setState({
              showPicker: true,
              selectModel: false,
              itemList: a,
            });

When I call console.log("Values:", this.state.itemList), I get the expected response:

Values: ["Select a Manufacturer", "Datex", "Ohmeda"]

Render:

this.state.showPicker && this.state.itemList != null ?
                    <View style={{ 
                      bottom: '0%', 
                      flexDirection: 'column', 
                      flex: 0.37, 
                      backgroundColor: '#b8b8b8', 
                      justifyContent: 'center', 
                      alignItems: 'center' }}
                    >
                      <View style={{  backgroundColor: '#b8b8b8', width: '100%' }}>
                        <Button title="Done" color={Platform.OS === "ios" ? "007AFF" : "#969696"} onPress={() => this.onPressHide()} />
                      </View>
                      <View style={styles.container2}>
                        <Picker style={styles.picker}
                          selectedValue={this.state.selectedItem}
                          itemStyle={{ color: "black", backgroundColor: "#b8b8b8", fontSize: 26 }}
                          onValueChange={(index) => this.onPickerSelect(index)}
                        >
                          {this.state.itemList.map((value, i) => (
                            <PickerItem label={value} value={i} key={"money" + value} />
                          ))}
                        </Picker>
                      </View>
                    </View>

I believe this is an issue with styling, but I'm not sure where I have made a mistake.

Styles:

picker: {
    width: "100%",
  },
  container2: {
    flex: 0.84,
    bottom: "0%",
    width: '100%',
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#b8b8b8',
  },

Here is a screenshot of the issue:

Screenshot_1564062555

Any help would be greatly appreciated!

@amanpates
Copy link
Author

Using version ^1.2.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant