Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
286 views
in Technique[技术] by (71.8m points)

javascript - React Native Picker Not Rendering Options

I'm trying to implement a select dropdown menu in a React Native application using npm's react-native-dropdown-picker package.

I successful did it in one of the application's views/screens and tried to replicate by the same way but the dropdown menu is not rendering the options.

Checking the redux's store is possible to see the data that should be rendered, and in other view it does render. The data is the same for both screens such as the picker component.

return (
    <>
      <DefaultHeader navigation={navigation} />
      <Container>
        <ScrollView
          refreshControl={
            <RefreshControl
              refreshing={refreshing}
              onRefresh={() => setRefreshing(true)}
            />
          }>
          <SalesAccountFilter /> // <-- Dropdown is rendered but dont render options
          {isLoading === true ? (
            <View style={{marginTop: '50%'}}>
              <Spinner color="#054785" />
            </View>
          ) : (
            <Content>
              ...some content
            </Content>
          )}
        </ScrollView>
      </Container>
    </>
);

In the other screen that the dropdown is implemented in the exactly same way it is working fine. There is no error about it on the console. In the following snippet is the implementation of "SalesAccountFilter".

const styles = StyleSheet.create({
  picker: {
    maxWidth: 320,
    minWidth: 320,
    color: 'black',
    zIndex: 1000,
  },
  pickerPlaceholder: {
    color: '#bfc6ea',
  },
});
...
  return (
    <DropDownPicker
      style={styles.picker}
      items={[...accounts]}
      defaultValue={null}
      placeholder="Select an account . . ."
      placeholderStyle={styles.pickerPlaceholder}
      containerStyle={{height: 40, width: 320}}
      labelStyle={{
        fontSize: 14,
        textAlign: 'left',
        color: '#000',
      }}
      itemStyle={{justifyContent: 'flex-start'}}
      dropDownStyle={{backgroundColor: '#fafafa'}}
      onChangeItem={handleSelected}
      searchable={true}
      searchablePlaceholder="Search account"
      searchableError={() => <Text>Not found</Text>}
      activeLabelStyle={{color: 'blue'}}
    />
  );
**Versions:** 
Ubuntu 20.04lts;
Node v15.5.0;
React Native Picker 1.9.8;
React 17.0.1;
Nativebase 2.15.0;
React Native 0.63.4;
Emulator: Pixel 4 (latest build);

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...