简体   繁体   中英

react native show the other component depends on the picker choice

I want to show the hidden picker if the first picker has choose something.

How to show some component when picker changes

{
              this.state.showme ?
                <View>
                  <Picker
                    selectedValue={this.state.PickerClearance}
                    style={styles.pickercont}
                    onValueChange={handlePickerChange}>
                    {/* onValueChange={(itemValue, itemIndex) => this.setState({ PickerClearance: itemValue })}> */}
                    <Picker.Item label='Certificate Type' value='0' />
                    <Picker.Item label="Barangay Certificate" value="barangay certificate" />
                    <Picker.Item label="Barangay Clearance" value="barangay clearance" />
                  </Picker>
                </View>
                :
                <View>
                  <Picker
                    selectedValue={this.state.PickerClearance}
                    style={styles.pickercont}
                    onValueChange={(itemValue, itemIndex) => this.setState({ PickerClearance: itemValue })}>
                    <Picker.Item label='Type of Certificates' value='0' />
                    <Picker.Item label="Barangay Certificate" value="barangay certificate" />
                    <Picker.Item label="Barangay Clearance" value="barangay clearance" />
                  </Picker>
                </View>
            }

You could use a Modal . You could design the Modal in such a way that it looks like a picker. By using the boolean state value you can prompt the modal anytime you want. Elements in the modal could be structured in terms of a Flatlist . If you want a sample code do comment.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM